KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to separate form validation logic: public function contactAction() { $form = $this->createForm(new ContactType()); $request = $this->get('request'); if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { $mailer = $this->get('mailer'); // .. setup a message and send it return $this->redirect($this->generateUrl('_demo')); } } return array('form' => $form->createView()); } I want to translate into 2 separate actions: public function contactAction() { $form = $this->createForm(new ContactType()); return array('form' => $form->createView()); } public function contactSendAction() { $form = $this->createForm(new ContactType()); $request = $this->get('request'); if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { $mailer = $this->get('mailer'); // .. setup a message and send it using return $this->redirect($this->generateUrl('_demo')); } } // errors found - go back return $this->redirect($this->generateUrl('contact')); } The problem is that when errors exist in the form - after form validation and redirect the do NOT showed in the contactAction. (probably they already will be forgotten after redirection - errors context will be lost)
Tags (comma-separated)
Save Edits
Cancel