Skip to content

HTML for expanded choice widgets not the best #131

@pbowyer

Description

@pbowyer

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions