I need to put in the same page the login form and the registration form. I'm using Symfony 3.2 and FOS User Bundle.
I found this: How to merge login and register form in one template on FOSUserBundle
Which was my first approach, but there is a problem. On validation error, the page gets redirected to another route (with only the template of the submitted form displaying). The problem is that the SecurityController and RegistrationController doesn't know of the controller which renders both FOS controllers in Twig, they just display the form template. With this approach, I can't override the template the fos controllers are displaying to display the main template, becuase that would generate an infinite recursion.
I tried overriding the fos controllers to do a redirect on a validation error of the form, but the redirect makes the validation messages get lost.
I also tried forwarding the request to both fos SecurityController and RegistrationController ( like this: http://symfony.com/doc/current/controller/forwarding.html ) but for the check action of the login, I get:
RuntimeException 'You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.'.
It's already configured and was working, but forwarding the request directly to the controller seems to break it (I couldn't figure out how is the login check being procesed really, as the check method returns only a runtime exception)
The last solution I could think of is to create both forms in the new controller, but I don't know how to call the fos user login check manually (for the registration I could just copy all the registerAction from RegistrationController).
Thanks for your time.