Custom FOSUserBundle Login Template using Bootstrap Custom FOSUserBundle Login Template using Bootstrap symfony symfony

Custom FOSUserBundle Login Template using Bootstrap


You were almost there :)

you can include the login form in any other template using the render function.

{% render controller("FOSUserBundle:Security:login") %}

... you just have to create app/Resources/FOSUserBundle/views/Security/login.html.twig and ommit the wrapping {% block fos_user_content %} found in FOSUserBundle's login.html.twig in order to have it return the form directly:

{% if error %}    <div>{{ error|trans }}</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 }}</label>    <input type="text" id="username" name="_username" value="{{ last_username }}" required="required" />    <label for="password">{{ 'security.login.password'|trans }}</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 }}</label>    <input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans }}" /></form>

Then adjust it to fit your template.


Richard Miller's post has helped me achieve what I was trying to do.

http://richardmiller.co.uk/2013/02/18/symfony2-ajax-and-full-page-templates/

{% extends app.request.attributes.get('partial')     ? '::ajax-layout.html.twig'     : '::full-layout.html.twig' %}

I couldn't get app.request.partial to work, and decided choosing based on xmlRequest wasn't ideal.