Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding FOSUserBundle Login Form

Im following the documentation here:https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.rst

I chose to Create A Child Bundle And Override Template so in my bundle I have

class MyBundle extends Bundle
{
    //declare bundle as a child of the FOSUserBundle so we can override the parent bundle's templates
    public function getParent()
    {
        return 'FOSUserBundle';
    }

}

In my bundle I have added the following files

MyBundle
      \Resources
               \views
                     \Security
                      login.html.twig

Matching the FOS bundle structure as mentioned in the documentation

login.html.twig

{% extends 'AnotherBundle::layout.html.twig' %}

{% block title %}Log In{% endblock %}

{% block content %}
    {% block fos_user_content %}{% endblock %}
{% endblock %}

When I go to the login page my header loads fine but there's no login form, what am doing wrong?

like image 336
jriggs Avatar asked Nov 05 '13 15:11

jriggs


1 Answers

Because you didn't write the code that render the login form.

open /vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Resources/views/Security/login.html.twig, copy the code in the fos_user_content block to your custom login.html.twig, reload the page, then you'll see the form.

If you want to customize the form, rewrite the code you've copied.

like image 117
yanyabo111 Avatar answered Oct 30 '22 14:10

yanyabo111