I know that this question is perfectly answered in FOSUserBundle documentation, but yet I can't solve my problem.
I am trying to make an own login page using FOSUserBundle.
I have a main.html.twig
that is EXACTLY the same as the login.html.twig
included in the FOSUserBundle source.
The only difference is that main.html.twig is in my own bundle structure and login.html.twig is in FOSUserBundle folder structure.
I reach both /login
and /main
. I resolve them and the render starts.
But when accessing /main
, I get the following error:
Twig_Error_Runtime: Variable "csrf_token" does not exist in "AcmeStoreBundle:Main:main.html.twig" at line 5
The code is known by the FOSUserBundle users, but anyway I paste it here:
<form action="{{ path("fos_user_security_check") }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
<label for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>
<input type="text" id="username" name="_username" value="" />
<label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
<input type="password" id="password" name="_password" />
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
<label for="remember_me">{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}</label>
<input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
The variable "csrf_token" is somehow not recognized from outside FOSUserBundle. Or something else that I am not getting.
Any clue over there?