public function addAction()
 {
     $form = new CommentForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $comment = new Comment();
         $form->setInputFilter($form->getInputFilter());
         $form->setData($request->getPost());
         //
         if ($form->isValid()) {
             $data = $request->getPost()->toArray();
             unset($data['submit']);
             try {
                 //\Zend\Debug\Debug::dump($data);die();
                 $this->getCommentTable()->saveComment($data);
                 return $this->redirect()->toRoute('comment');
             } catch (\Exception $e) {
                 $this->flashMessenger()->addMessage('there was an error');
                 return $this->redirect()->toRoute('comment', array('controller' => $this, 'action' => 'add'));
             }
         }
         //                $comment->exchangeArray($form->getData());
         //                return $this->redirect()->toRoute('comment');
         //            }
     }
     return array('form' => $form);
 }
Exemple #2
0
 /**
  * This function add a comment
  * @return type
  */
 public function postcommentAction()
 {
     $form = new CommentForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $comment = new Comment();
         $form->setInputFilter($comment->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $request->getPost()->toArray();
             \Zend\Debug\Debug::dump($data);
             die;
             //                $comment->exchangeArray($form->getData());
             $save = $this->getCommentTable()->saveComment($data);
             return $this->redirect()->toRoute('music');
         }
         return array('form' => $form);
     }
 }