public function addAction() { //$ddl_faq_category = Zend_Registry::get('ddl_faq_category'); $faqs = new Application_Model_Faqs(); $ddl_faq_category = $faqs->fetchCategoryItems(1); $this->view->ddl_faq_category = $ddl_faq_category; if ($this->request->isPost()) { $category = trim($this->request->category); $questions = trim($this->request->questions); $answer = trim($this->request->answer); $action = trim($this->request->reqaction); //echo $questions.'----'.$answer; die; if (empty($category)) { $adderror = 'A name must be provided for the new folder.'; return $this->_forward($action, $page, null, array('adderror' => $adderror)); } $faqs = new Application_Model_Faqs(); $userid = $this->user->getId(); $faqs->add($category, $questions, $answer, $userid); return $this->_redirect('faq/index'); } }
public function FaqAction() { // Defaults $error = null; $status = null; $faqs = new Application_Model_Faqs(); $list = $faqs->get(); if ($this->request->isPost()) { // see what kind of action was taken $action = $this->request->action; $id = trim($this->request->id); $title = trim($this->request->title); $content = trim($this->request->content); $active = (bool) trim($this->request->active); switch ($action) { case 'Update': if ($faqs->update($id, $title, $content, $active)) { $status = true; } else { $error = $faqs->getError(); } break; case 'Add': if ($faqs->add($title, $content, $active)) { $status = true; } else { $error = $faqs->getError(); } break; default: $error = 'Request not recognized, please try again.'; } } $this->view->error = $error; $this->view->status = $status; $this->view->list = $list; }