maraujop/django-crispy-forms — pull request #358 by dessibelle (2014-08-21 11:05:29+00:00)
Title: Fix for alignment of stacked checkboxes and radio buttons in Bootstrap 3

Modified layout for checkboxes and radio buttons with Bootstrap 3, so that stacked widgets align with their inline counterparts (as well as other form fields).

### The Problem
Stacked and inline fields doesn not align:

![Before fix: Stacked and inline fields does not align](http://i.imgur.com/pYm3OBg.png)

...but with the changes in this commit, they will:

![After fix: Stacked and inline fields align](http://i.imgur.com/FlnRMAs.png)

#### Code used for this example

# Fields
checkbox_inline = forms.TypedChoiceField(
label=_('Checkbox Inline'),
widget=forms.CheckboxSelectMultiple,
choices=((1, 'Inline 1',), (2, 'Inline 2',), (3, 'Inline 3',), (4, 'Inline 4',),)
)

checkbox_stacked = forms.TypedChoiceField(
label=_('Checkbox Stacked'),
widget=forms.CheckboxSelectMultiple,
choices=((1, 'Stacked 1',), (2, 'Stacked 2',), (3, 'Stacked 3',), (4, 'Stacked 4',),)
)

radio_inline = forms.TypedChoiceField(
label=_('Radio Inline'),
widget=forms.RadioSelect,
choices=((1, 'Inline 1',), (2, 'Inline 2',), (3, 'Inline 3',), (4, 'Inline 4',),)
)

radio_stacked = forms.TypedChoiceField(
label=_('Radio Stacked'),
widget=forms.RadioSelect,
choices=((1, 'Stacked 1',), (2, 'Stacked 2',), (3, 'Stacked 3',), (4, 'Stacked 4',),)
)

# Layout Helper
self.helper.layout = Layout(
InlineCheckboxes('checkbox_inline'),
'checkbox_stacked',
InlineRadios('radio_inline'),
'radio_stacked',
)

### The Fix
In accordance with the [specifications](http://getbootstrap.com/css/#forms-controls) in Bootstrap (see section *Checkboxes and radios*) I have moved the `.checkbox` class to a parent `div` element for stacked widgets (only), and kept `.checkbox-inline` for inline elements only.