public function addeditAction() { // action body $oCategoryForm = new Application_Form_Category(); $this->view->categoryform = $oCategoryForm; if ($this->getRequest()->isPost()) { if ($oCategoryForm->isValid($this->getRequest()->getPost())) { $saFormDetails = $oCategoryForm->getValues(); $oCategoryExist = Doctrine::getTable('Model_Category')->checkCategoryExist($saFormDetails['id_users']); if (count($oCategoryExist) > 0 && $this->getRequest()->getParam('id_category') == "") { $this->view->errorMessage = "This category is already exist."; } elseif ($this->getRequest()->getParam('id_category') != "" && isset($oCategoryExist[0]) && $oCategoryExist[0]['id_category'] != $this->getRequest()->getParam('id_category')) { $this->view->errorMessage = "This category is already exist."; } else { $oCategory = new Model_Category(); $snIdUser = $oCategory->saveAndUpdateCategoryDetails($oCategory, $saFormDetails, $this->getRequest()->getParam('id_category') != 0 ? $this->getRequest()->getParam('id_category') : ''); $this->_redirect('/admin/category/list'); } } } elseif ($this->getRequest()->getParam('id') != '') { $oCategory = Doctrine::getTable('Model_Category')->getCategoryDetailById($this->getRequest()->getParam('id')); $oCategoryForm->populate($oCategory[0]); } $this->view->param = $this->getRequest()->getParam('id') ? $this->getRequest()->getParam('id') : ''; }