/** Edit a ruler * @access public * @return void * @throws Pas_Exception_Param */ public function editrulerAction() { if ($this->getParam('id', false)) { $form = new RulerForm(); $form->submit->setLabel('Update details on database'); $this->view->form = $form; if ($this->_request->isPost()) { if ($form->isValid($this->_request->getPost())) { $rulers = new Rulers(); $where = array(); $where[] = $rulers->getAdapter()->quoteInto('id = ?', (int) $this->getParam('id')); $rulers->update($form->getValues(), $where); $this->getFlash()->addMessage($form->getValue('issuer') . '\'s information updated!'); $this->redirect($this->_redirectUrl . 'rulers/period/' . $form->getValue('period')); } else { $this->getFlash()->addMessage($this->_formErrors); $form->populate($this->_request->getPost()); } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $rulers = new Rulers(); $ruler = $rulers->fetchRow('id=' . $id); if (count($ruler)) { $form->populate($ruler->toArray()); } else { throw new Pas_Exception_Param($this->_nothingFound); } } } } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }