如何覆盖FosUser注册表单布局的布局. [英] How to override the layout of the FosUser registration form layout.

查看:52
本文介绍了如何覆盖FosUser注册表单布局的布局.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何覆盖注册表格的布局

How can I override the layout of the registration form

当前表单为

  -username 
  -email  
  -password  
  -verification  

我要覆盖此表单的布局,比方说,每行两个问题

I want the override the layout of this form, lets say, two questions per row

 -username      -email
 additional text   
 -password      -verification

我了解如何编写视图(树枝) register.html.twig调用register_content.html.twig 使用哪个

I understand how to write the views (twigs) register.html.twig calls register_content.html.twig which uses;

{{ form_widget(form) }}

我该如何覆盖 {{ form_widget(form) }}吗?

how do i override the {{ form_widget(form) }} ?

推荐答案

您必须覆盖FosUserBundle注册表单模板.

You have to override FosUserBundle registration form template.

您可以通过以下方式完成覆盖:

You can accomplish an override in the following ways:

  • 将具有相同名称的模板定义到app/resources目录. 在一起使用相同名称"时,您必须重现相同的结构 捆.因此,如果您的模板位于其中,即 FosUserBundle/views/mainTemplate.html.twig您必须通过以下方式覆盖它 在app/resources/FosUserBundle/views中创建一个新的模板,然后 称之为mainTemplate.html.twig

  • Define a template with same name into app/resources directory. Together "same name" you have to reproduce the same structure of the bundle. So, if your template is in, i.e., FosUserBundle/views/mainTemplate.html.twig you have to override it by creating a new one template in app/resources/FosUserBundle/views and call it mainTemplate.html.twig

您必须从头开始创建新的包,并覆盖getParent() 方法,该方法必须返回包含您所用的捆绑包名称的字符串 要覆盖(FosUserBundle).现在,如果您在 与原件相同的位置,则已将其覆盖.这 不建议使用此方法,因为您还必须重写控制器.

You have to create a new bundle from scratch and override getParent() method that have to return a string containing bundle name that you want to override ( FosUserBundle ). Now if you create a new template in the same position of the original, you have overwritten it. This method is not recommended since you have to override controller also.

这篇关于如何覆盖FosUser注册表单布局的布局.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆