Bootstrap   发布时间:2022-04-18  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了symfony – 使用Bootstrap自定义FOSUserBundle登录模板大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经安装了Symfony2,FOS用户包和Twitter Bootstrap.

然后我设置/app/resources/FOSUserBundle/views/layout.html.twig模板以覆盖FOSUserBundle以使用我的网站模板.

如果我在主页上有/ login的链接,这一切都有效.

现在我想实现一个hero template这样的模板,其中登录表单是主模板的一部分.

我最接近的是在主模板中使用它:

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

我可以覆盖布局html以不扩展主模板,但这将从/ login中删除所有样式

我有什么想法可以处理这两种情况吗?

解决方法

你快到了:)

您可以使用渲染功能在任何其他模板中包含登录表单.

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

…你只需创建app / resources / FOSUserBundle / views / Security / login.html.twig并省略FOSUserBundle的login.html.twig中的包装{%block fos_user_content%},以便直接返回表单:

{% 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>

然后调整它以适合您的模板.

大佬总结

以上是大佬教程为你收集整理的symfony – 使用Bootstrap自定义FOSUserBundle登录模板全部内容,希望文章能够帮你解决symfony – 使用Bootstrap自定义FOSUserBundle登录模板所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。