/** Edit a specific period */ public function editperiodAction() { if ($this->_getParam('id', false)) { $form = new PeriodForm(); $form->submit->setLabel(self::UPDATE); $this->view->form = $form; if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) { if ($form->isValid($form->getValues())) { $periods = new Periods(); $where = array(); $where[] = $periods->getAdapter()->quoteInto('id = ?', $this->_getParam('id')); $periods->update($form->getValues(), $where); $this->_flashMessenger->addMessage('Period information updated'); $this->_redirect($this->_redirectUrl . 'periods'); } else { $form->populate($form->getValues()); } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $periods = new Periods(); $period = $periods->fetchRow('id =' . $id); if (count($period)) { $form->populate($period->toArray()); } else { throw new Pas_Exception_Param($this->_nothingFound); } } } } else { throw new Pas_Exception_Param($this->_missingParameter); } }