1 : <?php
2 : class CommentController extends Zend_Controller_Action
3 1 : {
4 : protected $_session;
5 :
6 : public function init()
7 : {
8 8 : $this->_session = new Zend_Session_Namespace('comment');
9 8 : }
10 :
11 : public function indexAction()
12 : {
13 1 : $form = new Application_Form_Comment(array (
14 1 : 'action' => $this->_helper->url('send-comment'),
15 1 : 'method' => 'POST',
16 1 : ));
17 1 : if (isset ($this->_session->commentForm)) {
18 0 : $form = unserialize($this->_session->commentForm);
19 0 : unset ($this->_session->commentForm);
20 0 : }
21 1 : $this->view->form = $form;
22 1 : }
23 :
24 : public function sendCommentAction()
25 : {
26 7 : $request = $this->getRequest();
27 7 : if (!$request->isPost()) {
28 1 : return $this->_helper->redirector('index');
29 : }
30 6 : $form = new Application_Form_Comment();
31 6 : if (!$form->isValid($request->getPost())) {
32 5 : $this->_session->commentForm = serialize($form);
33 5 : return $this->_helper->redirector('index');
34 : }
35 1 : $values = $form->getValues();
36 1 : $this->view->values = $values;
37 1 : }
38 : }
39 :
40 :
41 :
|