From: Andrey Kutejko Date: Tue, 25 Jun 2013 20:51:30 +0000 (+0300) Subject: do not intercept form validation errors X-Git-Tag: 0.5~206 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=125a28d5dc66a36be8bc8ad6411e762cae9b2786;p=ipf.git do not intercept form validation errors --- diff --git a/ipf/form/model.php b/ipf/form/model.php index 07b52f2..e951121 100644 --- a/ipf/form/model.php +++ b/ipf/form/model.php @@ -125,30 +125,21 @@ class IPF_Form_Model extends IPF_Form function save($commit=true) { - if ($this->isValid()) { - $this->model->SetFromFormData($this->cleaned_data); - try{ - $this->model->save(); - $rels = $this->model->getTable()->getRelations(); - foreach($rels as $rname=>$rel){ - if (isset($this->cleaned_data[$rname])){ - $this->model->unlink($rel->getAlias()); - if (is_array($this->cleaned_data[$rname])){ - $this->model->link($rel->getAlias(),$this->cleaned_data[$rname]); - } - } - } - return $this->model; - } catch(IPF_ORM_Exception_Validator $e) { - $erecords = $e->getInvalidRecords(); - $errors = $erecords[0]->getErrorStack(); - foreach($errors as $k=>$v){ - echo $k, ' '; - print_r($v); + if (!$this->isValid()) + throw new IPF_Exception_Form(__('Cannot save the model from an invalid form.')); + + $this->model->SetFromFormData($this->cleaned_data); + $this->model->save(); + $rels = $this->model->getTable()->getRelations(); + foreach ($rels as $rname => $rel) { + if (isset($this->cleaned_data[$rname])) { + $this->model->unlink($rel->getAlias()); + if (is_array($this->cleaned_data[$rname])) { + $this->model->link($rel->getAlias(),$this->cleaned_data[$rname]); } } } - //throw new IPF_Exception_Form(__('Cannot save the model from an invalid form.')); + return $this->model; } }