braincrafted / bootstrap-bundle

BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 by providing templates, Twig extensions, services and commands.

Home Page:http://bootstrap.braincrafted.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTML for expanded choice widgets not the best

pbowyer opened this issue · comments

I believe I've found a bug in the markup Twig outputs for expanded choices, using block choice_widget_expanded. The generated HTML (reformatted for ease of reading) is:

  <div class="form-group">
    <label class="control-label required">Gender</label>

    <div id="application_gender">
      <div class="form-group">
        <div class="radio">
          <label for="application_gender_0" class="required"><input type="radio" id=
          "application_gender_0" name="application[gender]" required="required" value="m"
          checked="checked"> Male</label>
        </div>
      </div>

      <div class="form-group">
        <div class="radio">
          <label for="application_gender_1" class="required"><input type="radio" id=
          "application_gender_1" name="application[gender]" required="required" value=
          "f"> Female</label>
        </div>
      </div>
    </div>
  </div>

The issue? Note the extra <div class="form-group"> divs around every radio button. This causes problems with styling, as Bootstrap doesn't expect nested form groups; it also makes displaying jQuery Validation errors harder, as the structure changes for expanded choices vs single radio/checkbox markup.

I have hacked around in the Twig template, but I've only had success at breaking Twig...