-
Notifications
You must be signed in to change notification settings - Fork 359
Closed
Description
As a checkbox has no label, it is positioned with an offset.
This should be inferred from the lable_col parameter of the form, but it seems to be set to a default value (col-sm-offset-2) for the checkbox
<%= bootstrap_form_for(Event.new, layout: :horizontal, label_col: 'col-sm-1', control_col: 'col-sm-3',
:html => { :role => 'form', :class => 'form-horizontal' }) do |f| %>
<%= f.text_field :name %>
<%= f.form_group :offense do %>
<%= f.check_box :offense %>
<% end %>
<%= f.number_field :points %>
<% end %>produces this form content:
<div class="form-group">
<label class="control-label col-sm-1" for="event_name">Name</label>
<div class="col-sm-3">
<input class="form-control" id="event_name" name="event[name]" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-sm-3 col-sm-offset-2">
<div class="checkbox">
<label for="event_offense">
<input name="event[offense]" type="hidden" value="0" />
<input id="event_offense" name="event[offense]" type="checkbox" value="1" /> Offense
</label>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-1" for="event_points">Points</label>
<div class="col-sm-3">
<input class="form-control" id="event_points" name="event[points]" type="number" />
</div>
</div>When the form_group has the label_col option explicitly set
<%= f.form_group :offense, label_col: 'col-sm-1' do %>
<%= f.check_box :offense %>
<% end %>everything is fine.
-> seems that passing on the label_col option to the form_group does not work correctly.
Metadata
Metadata
Assignees
Labels
No labels