Example #1
0
 public function updateAction()
 {
     if (!$this->_hasParam('id')) {
         return $this->_redirect('/contact/index/page/1');
     }
     $form = new Application_Form_Contact();
     $persons = new Application_Model_Contacts();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->_getAllParams())) {
             $model = new Application_Model_Contacts();
             $model->save($form->getValues(), $this->_getParam('id'));
             return $this->_redirect('/contact/index/page/1');
         }
     } else {
         $row = $persons->getRow($this->_getParam('id'));
         if ($row) {
             $form->populate($row->toArray());
         }
     }
     $this->view->form = $form;
 }