public function commentsAction() { $request = $this->getRequest(); $form = new Application_Form_Comments(); if ($this->getRequest()->isPost()) { if ($form->isValid($request->getPost())) { $comment = new Application_Model_Comments($form->getValues()); $mapper = new Application_Model_CommentsMapper(); $mapper->save($comment); return $this->_helper->redirector('index'); } } $this->view->form = $form; }
public function createAction() { $form = new Application_Form_Comments(); $comments = new Application_Model_Comments(); if ($this->_request->isPost()) { if ($form->isValid($this->_request->getPost())) { $comments->insert($form->getValues()); $this->_redirect('/comment/retrieve'); } else { $form->populate($form->getValues()); } } $this->view->form = $form; }
public function editAction() { $authorization = Zend_Auth::getInstance(); $identity = $authorization->getIdentity(); $form = new Application_Form_Comments(); $model = new Application_Model_Comments(); //$this->view->courses = $model->editCourse(); $id = $this->getRequest()->getParam('id'); $comment_data = $model->getCommentById($id); $form->populate($comment_data[0]); if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getParams())) { $model = new Application_Model_Comments(); $model->editComment($form->getValues(), $identity->id); //$this->view->identity->id $this->redirect("/comments/list"); } } $this->view->{$form} = $form; $this->render('list'); }