public function editAction() { $this->view->title = "Edit food category"; $this->view->headTitle($this->view->title, 'PREPEND'); $form = new Form_Fooditem(); $form->submit->setLabel('Save'); $this->view->form = $form; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $id = (int) $form->getValue('id'); $name = $form->getValue('name'); $note = $form->getValue('note'); $fooditems = new Model_DbTable_FoodItems(); $fooditems->updateFooditem($id, $name, $note); $this->_redirect('/fooditem'); } else { $form->populate($formData); } } else { $id = $this->_getParam('id', 0); if ($id > 0) { $fooditems = new Model_DbTable_FoodItems(); $form->populate($fooditems->getFooditem($id)); } } }