public function updateAction()
 {
     $id = $this->_request->getParam('id');
     // fetch the current item
     $mdlMenuItem = new Application_Model_DbTable_MenuItem();
     $currentMenuItem = $mdlMenuItem->find($id)->current();
     // fetch its menu
     $mdlMenu = new Application_Model_DbTable_Menu();
     $this->view->menu = $mdlMenu->find($currentMenuItem->menu_id)->current();
     // create and populate the form instance
     $frmMenuItem = new Application_Form_MenuItem();
     $frmMenuItem->setAction('/menuitem/update');
     // process the postback
     if ($this->_request->isPost()) {
         if ($frmMenuItem->isValid($_POST)) {
             $data = $frmMenuItem->getValues();
             $mdlMenuItem->updateItem($data['id'], $data['label'], $data['link']);
             $this->_request->setParam('menu', $data['menu_id']);
             return $this->_forward('index');
         }
     } else {
         $frmMenuItem->populate($currentMenuItem->toArray());
     }
     $this->view->form = $frmMenuItem;
 }
예제 #2
0
 public function deleteAction()
 {
     $id = $this->_request->getParam('id');
     $mdlMenu = new Application_Model_DbTable_Menu();
     $mdlMenu->deleteMenu($id);
     $this->_forward('index');
 }