Symfony2 how to render Checkboxes?

前端 未结 3 515
醉话见心
醉话见心 2021-01-03 10:18

I have a formbuilder form with a multiple choice list of countries. When I render them on my form like this:

{{ form_widget(edit_form.countries) }}
<         


        
3条回答
  •  孤街浪徒
    2021-01-03 10:47

    From The Symfony Docs

    • Form theming
    • How to customize form rendering
    • Default form div layout

    What you basically need to do is to overload checkbox_widget block.

    {% form_theme form _self %}
    
    {% block checkbox_widget %}
    {% spaceless %}
        
    {% endspaceless %}
    {% endblock checkbox_widget %}
    

    Of course you can place your widgets in its own line with CSS (but it's not a Symfony2 question).

提交回复
热议问题