1

我为我的表单设置主题,如果该字段是复选框,我希望不显示标签

{% 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 %}
4

1 回答 1

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 %}
于 2013-06-05T18:30:31.340 回答