如果字段是复选框,我希望不显示标签
{% form_theme form with _self %}
{% block form_row %}
{% spaceless %}
<div class="mygroup">
{{form_label(form)}} # hide if checkbox
{{form_errors(form)}}
{{form_widget(form)}}
</div>
{% endspaceless %}
{% endblock %}
答案 0 :(得分:2)
过了一会儿,我在Google Group
找到了解决方案{% block form_row %}
{% spaceless %}
<div class="mygroup">
{% if 'checkbox' not in form.vars.block_prefixes %}
{{form_label(form)}}
{% endif %}
{{form_errors(form)}}
{{form_widget(form)}}
</div>
{% endspaceless %}
{% endblock %}