Skip to content
Advertisement

Rendering multiple forms on same page with Symfony 3

I’d like to show a login and a registration form on the same page. However it seems that we cannot render the same template with different form variables in different two actions in a controller.

Here is what I mean;

JavaScript

}

Above I have my login and registration action. I’d like to pass the ‘form’ variable to the same twig template that I render with login action. When I try to do that I’m getting the following exception.

JavaScript

Advertisement

Answer

I would do it like this

2 twig files

login.html.twig and register.html.twig – Every file render by himself the action

now the third twig file called baseLogin.html.twig

in this file, I render the two files (login and register) by calling controller

For example

baseLogin.html.twig

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement