/** * @param Request $request * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function postAction(Request $request) { /** @var \Doctrine\ORM\EntityManager $em */ $em = $this->getDoctrine()->getManager(); $webForm = $em->find('WebFormModule:WebForm', $this->webform_id); $form = $this->getForm($webForm); $form->handleRequest($request); $session = $this->get('session')->getFlashBag(); if ($form->isValid()) { $message = new Message(); $message->setData($form->getData())->setUser($this->getUser())->setWebForm($webForm)->setIpAddress($request->server->get('REMOTE_ADDR')); $this->persist($message, true); $this->sendNoticeEmails($webForm, $message); $session->add('success', $webForm->getFinalText() ? $webForm->getFinalText() : 'Сообщение отправлено.'); } else { $session->add('error', 'При заполнении формы допущены ошибки.'); $session->add('feedback_data', $request->request->all()); } return $this->redirect($request->getRequestUri()); }
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('status', 'choice', ['choices' => Message::getFormChoicesStatuses()])->add('comment'); }