/** Edit a surface treatment * @access public * @return void * @throws Pas_Exception_Param */ public function editsurfaceAction() { if ($this->getParam('id', false)) { $form = new SurfaceTreatmentsForm(); $form->submit->setLabel(self::UPDATE); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($this->_request->getPost())) { $surfaces = new SurfaceTreatments(); $where = array(); $where[] = $surfaces->getAdapter()->quoteInto('id = ?', $this->getParam('id')); $surfaces->update($form->getValues(), $where); $this->getFlash()->addMessage('Surface treatment information updated!'); $this->redirect($this->_redirectUrl . 'surfaces/'); } else { $form->populate($form->getValues()); } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $surfaces = new SurfaceTreatments(); $surface = $surfaces->fetchRow('id=' . $id); if (count($surface)) { $form->populate($surface->toArray()); } else { throw new Pas_Exception_Param($this->_nothingFound); } } } } else { throw new Pas_Exception_Param($this->_missingParameter, 500); } }