I want to add Login Section to the registration page.. Basically, the idea is, when the user goes to the registration page, the login section will be also available on the same page, in-case the user realizes that he already has an account. I am trying this but its not working…
//Registration_content.html.twig
<form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register">
{{ form_errors(form.email.first) }}
{{ form_errors(form.plainPassword.first) }}
{{ form_widget(form.email.first)}}
{{ form_widget(form.email.second)}}
<br />
{{ form_widget(form.plainPassword.first) }}
{{ form_widget(form.plainPassword.second) }}
<br />
{{ form_widget(form.country) }}
<br />
{% for choiceFormView in form.Position %}
{{ form_widget(choiceFormView) }} {{ form_label(choiceFormView) }}<br />
{% endfor %}
{% for choiceFormView in form.notification %}
{{ form_widget(choiceFormView) }} {{ form_label(choiceFormView) }}<br />
{% endfor %}
{{ form_rest(form) }}
<div>
<input type="submit" value="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}" />
</div>
</form>
What i want to add to this page is, the login page contents. But of course it is not working;
{% block fos_user_content %}
{% if error %}
<div>{{ error|trans({}, 'FOSUserBundle') }}</div>
{% endif %}
<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="{{ last_username }}" required="required" />
<br>
<br>
<label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
<input type="password" id="password" name="_password" required="required" />
<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') }}" />
</form>
What is the right way to approach this… I will have the login section on many pages as well. So the real question seems to be, how do I use fosuser login section on the other pages?
Just put
in any template of your page where you want the login form to be rendered.