public function signAction() { $request = $this->getRequest(); $form = new Application_Form_Guestbook(); if ($request->isPost() && $form->isValid($request->getPost())) { $comment = new Application_Model_Guestbook($form->getValues()); $mapper = new Application_Model_GuestbookMapper(); $mapper->save($comment); return $this->_helper->redirector('index'); } $this->view->form = $form; }
public function signAction() { $request = $this->getRequest(); $form = new Application_Form_Guestbook(); $mapper = new Application_Model_GuestbookMapper(); $blog_id = $this->getRequest()->getParam('id'); if ($blog_id) { $formData = $mapper->find($blog_id); $form->populate($formData); } if ($this->getRequest()->isPost()) { if ($form->isValid($request->getPost())) { $comment = new Application_Model_Guestbook($form->getValues()); $mapper->save($comment); $this->_helper->flashMessenger->addMessage('Saved'); return $this->_helper->redirector('index'); } } $this->view->form = $form; }