0
我要重写form_widget_simple
功能Symfony2的更改类名在树枝形式主题
{% block form_widget_simple %}
{% spaceless %}
{% set type = type|default('text') %}
{% if errors|length > 0 %}
{{dump(form.vars.attr)}}
{% endif %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{% endspaceless %}
{% endblock form_widget_simple %}
,但我不知道如何设置form.vars.attr['class']
内if
声明 了when我做set form.vars.attr['class'] = 'error';
我得到错误Unexpected token "punctuation" of value "." ("end of statement block" expected)
你想为''元素添加一个修复'class'(for css-classes)属性吗? –
是的,为现有的添加另一个'class' –