Symfony2 - theme for multiple forms(Symfony2 - 多种形式的主题)
问题描述
有没有办法在同一页面上为两个(或多个)表单使用不同的主题.我有 2 个表单,我想将主题X"用于第一个表单,将主题Y"用于第二个表单.
Is there way to use diffrent themes for two (or more) forms on the same page. I've 2 forms and I'd like to use theme "X" for first form and theme "Y" for second form.
推荐答案
您需要在显示表单之前声明您的主题.
You need to declare your theme before displaying your form.
你应该试试:
{% form_theme form 'ThemeX.html.twig' %}
{{ form(formX) }}
{% form_theme form 'ThemeY.html.twig' %}
{{ form(formY) }}
如果这不起作用(即第二个表单主题声明不会覆盖第一个),只需为您的第二个表单使用单独的模板并使用包含将其插入到您的父模板中.
If that doesn't work (ie. second form theme declaration doesn't overwrite the first one), just use a separate template for your second form and insert it in your parent template using an include.
试试 [http://symfony.com/doc/current/cookbook/form/form_customization.html#child-forms](this page) of symfony doc 了解更多信息
Try [http://symfony.com/doc/current/cookbook/form/form_customization.html#child-forms](this page) of symfony doc for more information
这篇关于Symfony2 - 多种形式的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Symfony2 - 多种形式的主题


基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何替换eregi() 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01