function editAction() { $this->view->title = 'Edit Template'; $form = new TemplateForm(array('legend' => $this->view->title)); $form->submit->setLabel('Update'); $this->view->form = $form; if ($this->_request->isPost()) { $form_data = $this->_request->getPost(); if ($form->isValid($form_data)) { $templates = new Templates(); $id = $form->getValue('id'); $row = $templates->fetchRow('id=' . $id); $row->name = $form->getValue('name'); $row->width = $form->getValue('width'); $row->height = $form->getValue('height'); $row->save(); $this->saveData($id); $this->_redirect('/template/view/id/' . $id); } else { $form->populate($form_data); } } else { $id = $this->_request->getParam('id'); if ($id > 0) { $templates = new Templates(); $row = $templates->fetchRow('id=' . $id); $form->populate($row->toArray()); } } $this->_helper->viewRenderer('form'); }