douyi6922 2014-06-24 12:25
浏览 13
已采纳

覆盖FOS用户包中的“更改密码”模板

I did some research and sadly couldn't find any help for that.

So I'm rendering the FOSUserBundle ChangePasswordAction into a template of mine, but it displays the default template given from the vendor.

My template where the controller is rendered:

{% block body %}
    <h2>Einstellungen</h2>
    <br/>
    <h4>Ändern Sie ihr Passwort</h4>
    {% render controller("FOSUserBundle:ChangePassword:changePassword") %}
{% endblock %}

My template for the ChangePasswordAction, the path is app/Resources/FOSUserBundle/views/ChangePassword/changePassword.html.twig:

{% block fos_user_content %}
    {% trans_default_domain 'FOSUserBundle' %}

    <form action="{{ path('fos_user_change_password') }}" {{ form_enctype(form) }} method="POST" class="fos_user_change_password">
        {{ form_start(form) }}
            {{ form_errors(form) }}
            <p><span class="edit_left_date">{{ form_label(form.current_password, 'Jetziges Passwort') }} </span>
                <span class="edit_right">{{ form_widget(form.current_password) }}</span></p>
            <p><span class="edit_left_date">{{ form_label(form.new_password, 'Neues Passwort') }} </span>
                <span class="edit_right">{{ form_widget(form.new_password) }}</span></p>
            <p><span class="edit_left_date">{{ form_label(form.new_password_confirmation 'Bestätigen Sie ihr neues Passwort') }} </span>
                <span class="edit_right">{{ form_widget(form.new_password_confirmation) }}</span></p>
            <div>
                <input type="submit" value="{{ 'Speichern'|trans }}" />
            </div>
        {{ form_end(form) }}
    </form>
{% endblock %}

What drives me crazy is that i render the login controller from the FOSUserBundle the same way in my layout.html.twig and it's working perfectly there.

The snippet of code from the layout:

{% block sidebar %}
    {% render controller("FOSUserBundle:Security:Login") %}
{% endblock %}

and the app/Resources/FOSUserBundle/views/Security/login.html.twig:

{% block fos_user_content %}
    <div class="teaser-header">Login</div>
        <form role="form" action="{{ path("fos_user_security_check") }}" method="post">
            <input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
            <div class="form-group">
                <label for="username">{{ 'MyLog Username'|trans }}</label>
                <input class="form-control" type="text" id="username" name="_username" placeholder="Your Username" required="required" />
            </div>
            <div class="form-group">
                <label for="password">{{ 'Password'|trans }}</label>
                <input class="form-control" type="password" id="password" name="_password" placeholder="Your Password" required="required" />
            </div>
            <input type="submit" id="_submit" name="_submit" value="{{ 'Segel setzen'|trans }}" />
            <a id="passwordForget" href={{ path('fos_user_resetting_request') }}>Password vergessen?</a>
        </form>
{% endblock %}

Am i missing something or what am i doing wrong so i can't override the changePassword Template?

  • 写回答

3条回答 默认 最新

  • douze2890241475 2014-06-24 14:23
    关注

    Moving from comments to an answer:

    Have you cleared your cache since adding the new template?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号