public function updateAction() { $id = $this->getRequest()->getParam('id'); $DbTable = new Application_Model_DbTable_Imie(); $obj = $DbTable->find($id)->current(); if (!$obj) { throw new Zend_Controller_Action_Exception('Błędny adres!', 404); } if ($this->getRequest()->isPost()) { $form = new Application_Form_Imie(); if ($form->isValid($this->getRequest()->getPost())) { $data = $form->getValues(); $obj->setFromArray($data); $obj->save(); return $this->_helper->redirector( 'edit', 'index', null, array('id' => $id) ); } $this->view->form = $form; } else { throw new Zend_Controller_Action_Exception('Błędny adres!', 404); } }
Listing 28.11. Metoda akcji update
Rozdział 28. Przetwarzanie formularza, czyli implementacja interfejsu CRUD