/** Edit an institution */ public function editAction() { $form = new InstitutionForm(); $form->details->setLegend('Edit institution details: '); $this->view->form = $form; if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) { if ($form->isValid($form->getValues())) { $where = array(); $where[] = $this->_institutions->getAdapter()->quoteInto('id = ?', $this->_getParam('id')); $update = $this->_institutions->update($form->getValues(), $where); $this->_flashMessenger->addMessage($form->getValue('institution') . '\'s details updated.'); $this->_redirect($this->_redirectUrl . 'institutions/'); } else { $form->populate($form->getValues()); } } else { // find id is expected in $params['id'] $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $insts = $this->_institutions->fetchRow('id=' . $id); $this->view->inst = $insts->toArray(); $form->populate($insts->toArray()); } } }
/** * Display form to create/edit a institution. * @param $args array optional, if set the first parameter is the ID of the institution to edit */ function editInstitution($args = array()) { $this->validate(); $this->setupTemplate(true); import('classes.manager.form.InstitutionForm'); $institutionForm = new InstitutionForm(!isset($args) || empty($args) ? null : (int) $args[0]); $institutionForm->initData(); $institutionForm->display(); }