diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 9e30c6769eb350e0a45f34d0da4334187151dffd..fe704cda6e892a198b8aacfcde0fda400e3d5c83 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -147,9 +147,9 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { $this->view->titre = $this->_getEditActionTitle($model); $this->_addModelToView($model); + if ($this->_setupFormAndSave($model)) { $this->_helper->notify($this->_definitions->successfulSaveMessage($model)); - $this->_redirectToEdit($model); $this->_definitions->doAfterEdit($model); } @@ -249,6 +249,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { protected function _setupFormAndSave($model) { $form = $this->_getForm($model); + $this->view->form = $form; if (!$this->_request->isPost()) return false; @@ -269,6 +270,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { } $model->updateAttributes($post); + if ((!$form->isValidModelAndArray($model,$this->_getPost()))) return false; @@ -315,12 +317,10 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { } return $form - ->populate($this->_getParams()) + ->populate($this->_request->getParams()) ->populate($this->_getFormValues($model)); } - protected function _getParams() { - return $this->_request->getParams(); - } + protected function _getFormValues($model) { return $model->toArray(); @@ -336,7 +336,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { } $form = $formClass::newWith( - array_merge($this->_getFormValues($model), $this->_getParams()), + array_merge($this->_getFormValues($model), $this->_request->getParams()), $custom_form ); $form->setAction($this->view->url());