渲染表单字段时添加了一个弄乱我样式的类。我想要做的就是在渲染字段时删除类,但是我该怎么做呢?我知道您可以为字段设置类,但我需要删除默认类。
我这样渲染:
{{ form_widget(form.plainPassword }}
我现在唯一能做到这一点的方法是转到供应商bootstrap_3_horizontal_layout
文件并删除该行:
{% block form_group_class -%}
col-sm-10 ///remove this
{%- endblock form_group_class %}
然而,这不是解决方案,因为您无法手动编辑供应商文件。我有哪些选择?如何实现我的需求?
答案 0 :(得分:0)
您可以为表单类型定义own theme,也可以手动添加html并使用raw form variables
答案 1 :(得分:0)
您应该检查the documentation about form theme "Application-wide Customizations"。
您可以创建一个表单主题模板,该模板扩展Meteor.methods({
add_new_email: function(address)
{
Accounts.addEmail(Meteor.userId(), address);
}
});
并覆盖bootstrap_3_horizontal_layout
块,如下所示:
form_group_class
然后将此模板设置为{% use 'bootstrap_3_horizontal_layout.html.twig' %}
{% block form_group_class %}{% endblock form_group_class %}
中的全局表单主题(假设它位于config.yml
中的MyAppBundle
)中:
form/my_form_theme.html.twig