I would suggest trying something like this:
$request = $this->get('request'); if ($request->getMethod() === 'POST') { if ($request->get('login') !== null) { $form_login->bindRequest($request); // Do your login logic here } else if ($request->get('forgottenpassword') !== null) { $form_password->bindRequest($request); // Do your forgotten password logic here } } Note that this assumes your form names 'login' and 'forgotpassword', if you've customised them then you'll need to change those strings Daniel On May 4, 8:42 pm, maboiteaspam <maboiteas...@wanadoo.fr> wrote: > Hi, > > I'm having problems when during POST rendering with two forms inside the > same view. > I created two routes, one for GET, one for POST. > GET route create the 2 Forms, and pass them to a Twig view. > POST view create, also, the 2 Forms, but it does bind request, and then > pass to twig template. > > The problem is that when i bind request, i do bind both forms, > > /** > * > * @extra:Route("/mon-espace-prive/me-connecter", > name="_do_customer_login", requirements={"_method"="POST"}) > * @extra:Template("SomeBundle::Customer/index.html.twig") > */ > public function loginAction() > { > $form_login = $this->get('form.factory')->create(new > LoginType()); > $form_password = $this->get('form.factory')->create(new > ForgottenPasswordType()); > > $request = $this->get('request'); > $form_login->bindRequest($request); > $form_password->bindRequest($request); > > return array('form_login' => $form_login->createView(), > 'form_password' => $form_password->createView()); > } > > But, bindRequest implies a validation of the request against the form. > > And so, when render comes the form validated by user is correctly > rendering (with errors and all the stuff required), > but the other form is showing unneccessary errors messages, like this : > The CSRF token is invalid. Please try to resubmit the form > > Email > This value should not be blank > > I expected to find a method like isActivate (or what ever you want) to > determine if a form has been submitted by user. > But there is no such things in Symfony\Component\Form\Form. > > Please, can some one explain me my mistakes here, i think i may have > missed something pretty big... > > Thanks by advance. -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en