SONATA用户捆绑/ FOS用户捆绑

时间:2015-05-21 16:34:58

标签: symfony fosuserbundle sonata-admin sonata-user-bundle


这是我第一次使用这个Bundle 我有一个小问题,正确显示注册某人的一面。
实际上,布局是重复的。我不知道为什么。我花了很多时间,但目前还没有答案。
我加入图片了解(左侧是正确的,但右侧不正确。 enter image description here

我按照以下说明操作:https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_templates.md
我的代码:
视图/ layout.html.twig

{% extends "EmooviofrontBundle::layout.html.twig" %}

{% block content %}
    <!-- Page Content -->
    <div class="col-lg-12">
        <!-- Page Heading/Breadcrumbs -->
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">Connexion
                </h1>
            </div>
        </div>
        <!-- /.row -->
        <div>
            {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
                {{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
                <a href="{{ path('fos_user_security_logout') }}">
                    {{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
                </a>
            {% else %}
                <a href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|trans({}, 'FOSUserBundle') }}</a>
            {% endif %}
        </div>

            {% for type, messages in app.session.flashBag.all %}
                {% for message in messages %}
                    <div class="{{ type }}">
                        {{ message|trans({}, 'FOSUserBundle') }}
                    </div>
                {% endfor %}
            {% endfor %}

        <div>
            {% block fos_user_content %}
            {% endblock fos_user_content %}
        </div>
    </div>
{% endblock %}

视图/安全性/ login.html.twig:

{% extends "SonataUserBundle:Security:base_login.html.twig" %}

视图/安全性/ base_login.html.twig:

{% extends "SonataUserBundle::layout.html.twig" %}

{% block fos_user_content %}
    <div class="row">
        <div class="col-md-6">
            <h3 class="compte">Déjà membre</h3>
            {% if error %}
                <div class="alert alert-danger alert-error">{{ error|trans({}, 'FOSUserBundle') }}</div>
            {% endif %}
            <form action="{{ path("fos_user_security_check") }}" method="post" role="form" class="form-horizontal" id="loginform">
                <input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>
                <div style="margin-bottom: 25px" class="input-group">
                    <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                    <input type="text" class="form-control" id="username" name="_username" value="{{ last_username }}" required="required" placeholder="E-mail">
                </div>
                <div style="margin-bottom: 25px" class="input-group">
                    <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
                    <input type="password" class="form-control" id="password" name="_password" required="required" placeholder="Mot de passe"/>
                </div>
                <div style="float:right; font-size: 80%; position: relative; top:5px; right:5px">
                    <a href="{{ path('fos_user_resetting_request') }}">{{ 'forgotten_password'|trans({}, 'SonataUserBundle') }}</a>
                </div>
                <div class="input-group">
                    <div class="checkbox">
                        <label for="remember_me">
                            <input type="checkbox" id="remember_me" name="_remember_me" value="on"/>
                                {{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}
                        </label>
                    </div>
                </div>
                <div style="margin-top:10px" class="form-group">
                    <!-- Button -->
                    <div class="col-sm-12 controls">
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-2">
                            <input type="submit" id="_submit" name="_submit" class="bg-black"
                               value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}"/>
                        </div>
                        <div class="col-sm-8">
                            <a class="bg-black " href="#">Connexion avec Facebook <img src="{{ asset('bundles/emoovio/uploads/social_network/facebook.png') }}" /></a>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="col-md-6">
            {% render controller("FOSUserBundle:Registration:register") %}
        </div>
    </div>
{% endblock fos_user_content %}

views / Registration / register_content.html.twig:

{% block register %}
<div class="col-md-6">
    <div class="panel-heading">
        <h2 class="panel-title">{{ 'title_user_registration'|trans({}, 'SonataUserBundle') }}</h2>
    </div>
    <div class="panel-body">
        <form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register form-horizontal">
            {{ form_widget(form) }}
            <div class="form-actions">
                <input type="submit" value="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}" class="btn btn-success pull-right" />
            </div>
        </form>
    </div>
</div>
{% endblock %}

有人遇到过这个问题吗...谢谢。

1 个答案:

答案 0 :(得分:2)

我在这里找到了解决方案:https://github.com/sonata-project/SonataUserBundle/issues/412

<{1>}中的

使用与原始内容相同的内容,不扩展任何布局:

app/Resources/FOSUserBundle/views/Registration/register.html.twig