Symfony 3.1 中的 Bootstrap 表单主题 [英] Bootstrap form theme in Symfony 3.1

查看:22
本文介绍了Symfony 3.1 中的 Bootstrap 表单主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何包含为 Bootstrap 3 设计的表单主题.这个选项是在 Symfony 2.6 中引入的,但在 Symfony 3.1 中它被移动或删除,因为这个解决方案不能正常工作:Symfony 2.6 的新功能:Bootstrap 表单主题.

I would like to know how to include a form theme designed for Bootstrap 3. This option was introduced in Symfony 2.6, but in Symfony 3.1 it was moved or deleted, becouse this solution does not work as it should: New in Symfony 2.6: Bootstrap form theme.

当我尝试设置时:

twig:
debug:            "%kernel.debug%"
strict_variables: "%kernel.debug%"
form:
    resources: ['bootstrap_3_layout.html.twig']

我收到了这条消息:

致命错误:未捕获的异常 'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException' 带有消息 'Unrecognized option "form" under "twig"' in ...

Fatal error: Uncaught exception 'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException' with message 'Unrecognized option "form" under "twig"' in ...

我知道

{% form_theme form 'bootstrap_3_layout.html.twig' %}

而且效果很好,但我想在配置文件中永久设置这个主题.

and it works very well, but I want to set this theme permanently in a config file.

推荐答案

我认为配置键已更改.

试试:

# app/config/config.yml
twig:
    form_themes:
        - 'bootstrap_3_layout.html.twig'
    # ...

http://symfony.com/doc/current/cookbook/form/form_customization.html#twig

这篇关于Symfony 3.1 中的 Bootstrap 表单主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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