Reputation: 2082
I am starting a new Symfony project and I'm using the FosUserBundle. I have my login and register page working, but I can't get my bootstrap form theme working for the login page. Note: it does work for the register form, because the form's variable is actually named form.
This is my template:
{% extends '@Frontend/Layout/home.html.twig' %}
{% form_theme form 'bootstrap_3_layout.html.twig' %}
{% block title %}Login{% endblock %}
{% block content %}
{% block fos_user_content %}{% endblock %}
{% endblock %}
I am overriding the original FosUserBundle's template using a child bundle. Again, this works for the register form, but not for the login form. When I go to the register page and I look at the source I find this:
<label class="control-label required" for="fos_user_registration_form_username">form.username</label>
As you can see, the label is called form.username, so the variable that holds the form is called form. I figured that's whny {% form_theme form %} worked, so I looked at the login page:
Variable "form" does not exist in FOSUserBundle::layout.html.twig at line 2
This was weird to me, so I removed the form theme and looked at the login page:
<label for="username">security.login.username</label>
So, I thought: the form is called security, so let's do this:
{% form_theme security 'bootstrap_3_layout.html.twig' %}
But, this did not work. My question: what variable is the login form stored in? I know that I can override the form, but I think it's weird that the forms are stored in different variables, so my second question is: why are the forms stored in different variables?
Upvotes: 1
Views: 748
Reputation: 66
I was running in the same issue some days ago. FOSUserBundle
isn't using the form component, so it has plain form templates. This means you can't use Form Theme here. So bad. :-(
Upvotes: 3