Bootstrap 3: formatted checkboxes with Symfony & Twig

Viewed 11554

How to create a formatted group of checkboxes as described in the Bootstrap documentation using the Symfony Form Factory and Twig?

Using something like

<div class="row">
  <div class="col-lg-4">
    {{ form_label(form.sample) }}
  </div>
  <div class="col-lg-8">
    {{ form_widget(form.sample) }}
  </div>
</div>

will not result in the needed output:

a) each checkbox within a Bootstrap 3 structure like:

<div class="radio">
  <label>
    <input type="radio" ... />Option one
  </label>
</div>

b) in addition the ability to output the checkboxes in two or more columns if needed:

<div class="row">
  <div class="col-lg-6 col-md-6">
    <div class="radio"> ... </div>
  </div>
  <div class="col-lg-6 col-md-6">
    <div class="radio"> ... </div>
  </div>
</div>
4 Answers
Related