问题描述
如何覆盖注册表格的布局
当前表格为
-username -email -password -verification
我要覆盖该表格的布局,可以说,每行两个问题
-username -email additional text -password -verification
我了解如何写视图(树枝) register.html.twig调用register_content.html.twig 使用;
{{ form_widget(form) }}
如何覆盖 {{ form_widget(form) }}?
推荐答案
您必须覆盖fosuserbundle登记表模板.
您可以通过以下方式完成覆盖:
-
将具有相同名称的模板定义为应用程序/资源目录. 一起"同名",您必须复制与相同的结构 捆.因此,如果您的模板在 fosuserbundle/views/naveremplate.html.twig您必须覆盖它 在应用程序/资源/fosuserbundle/views和 将其称为Maintemplate.html.twig
-
您必须从头开始创建一个新捆绑包() 必须返回包含包装名称的字符串的方法 想要覆盖(fosuserbundle).现在,如果您创建一个新模板 原始位置相同,您已经覆盖了它.这个 不建议使用方法,因为您还必须覆盖控制器.
问题描述
How can I override the layout of the registration form
Currently the form is
-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
I understand how to write the views (twigs) register.html.twig calls register_content.html.twig which uses;
{{ form_widget(form) }}
how do i override the {{ form_widget(form) }} ?
推荐答案
You have to override FosUserBundle registration form template.
You can accomplish an override in the following ways:
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
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.