コード例 #1
0
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new CommentForm();
     if ($request->isMethod('post')) {
         $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'));
         $form->bind(array_merge($request->getParameter($form->getName()), array('captcha' => $captcha)));
         if ($form->isValid()) {
             $form->save();
             $this->getUser()->setFlash('form_saved', true);
             $this->redirectBack();
         }
     }
     $this->forms['Comment'] = $form;
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: vik0803/helpdesk
 public function executeComment(sfWebRequest $request)
 {
     $comment = new Comment();
     $comment->setTicketId($request->getParameter('id'));
     $form = new CommentForm($comment);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $this->getUser()->setFlash('message', array('success', 'Отлично!', 'Комментарий добавлен.'));
         $comment = $form->save();
         $this->redirect('@tickets-show?id=' . $comment->getTicketId());
     } else {
         //$this->redirect('@tickets-show?id=' . $request->getParameter('id'));
         $this->form = $form;
     }
 }