Reputation: 3003
I'm trying to override the login and register templates for FOSUserBundle
but I can't get it working, I'm doing what documentation says, but nothing happens all I can see is the default templates :S
This is my app\Resources\FOSUserBundle\views\Security\login.html.twig
{% extends "FOSUserBundle::layout.html.twig" %}
{% block fos_user_content %}
{% if error %}
<div>{{ error|trans({}, 'FOSUserBundle') }}</div>
{% endif %}
<p>Login!</p>
<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" />
<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>
{% endblock fos_user_content %}
And this is my app\Resources\FOSUserBundle\views\layout.html.twig
{% extends '::base.html.twig' %}
{% block body %}
<div class="container">
{% for type, messages in app.session.flashbag.all() %}
{% for key, message in messages %}
<div class="flash-{{ type }}">
{{ message|trans({}, 'FOSUserBundle') }}
</div>
{% endfor %}
{% endfor %}
{% block fos_user_content %}{% endblock %}
</div>
{% endblock %}
Upvotes: 2
Views: 3017
Reputation: 3065
Just to bring some attention to an alternative for people that may end up here, as per Sam Dufel's comment, this was caused (for me) by the cache folder not fully clearing (itself an issue caused by vagrant sharing folders and permissions)
Manually deleting the app/cache folder fixes it.
Upvotes: 2
Reputation: 2342
Make sure you are extending fosUserBundle in your userbundle file:
<?php
namespace Radsphere\UserBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class RadsphereUserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
In addition, make sure the twig template, which you are extending, exists in the same folder structure like in FosUserBundle: For example I extended login.html.twig and its location is at
src/Radsphere/UserBundle/Resources/views/security/login.html.twig
Upvotes: 4