Ric*_*son 16 symfony twig twitter-bootstrap-3
我正在直接从手册中了解说明.我在config.yml中有这个配置设置
twig:
form:
resources: ['bootstrap_3_layout.html.twig']
Run Code Online (Sandbox Code Playgroud)
没有这么远,但在我的base.html.twig我有......
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"
integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r"
crossorigin="anonymous">
{% block stylesheets %}{% endblock %}
Run Code Online (Sandbox Code Playgroud)
当然,在base.html.twig底部适当调用jquery和boostrap.js
在我的任何模板中......
{% extends 'base.html.twig' %}
{% form_theme form 'bootstrap_3_layout.html.twig' %}
{% block body %} //etc. etc.
Run Code Online (Sandbox Code Playgroud)
我收到错误:
InvalidConfigurationException in ArrayNode.php line 317:
Unrecognized option "form" under "twig"
Run Code Online (Sandbox Code Playgroud)
他们是否更改了yml配置设置而未在手册中更新?
Jav*_*luz 25
在较新的Symfony版本中,您必须使用form_themes
而不是form.resources
:
# app/config/config.yml
twig:
form_themes: ['bootstrap_3_layout.html.twig']
Run Code Online (Sandbox Code Playgroud)
而且,您无需将其添加到模板中:
{% form_theme form 'bootstrap_3_layout.html.twig' %}
Run Code Online (Sandbox Code Playgroud)
您可以安全地删除该标记,表单仍将使用Bootstrap表单主题(因为您在config.yml
文件中全局配置它).
这是关于此的官方文档:http://symfony.com/doc/2.6/cookbook/form/form_customization.html#making-application-wide-customizations
归档时间: |
|
查看次数: |
2940 次 |
最近记录: |