Using Simple_form 2.0.2
The simple form code using HAML:
= f.input :remember_me, as: :boolean, inline_label: \'Remember me\'
But it ren
For whom it doesn't work
= f.input_field ...
Use this way
= f.check_box ...
With simple_form 2.1.0 and rails 3.0.20, none of the solutions listed here worked (I don't want to use f.input_field because it's an admission of defeat).
The missing part is the boolean_style option:
options.merge!({label: false, boolean_style: :inline})
I suggest you create a custom input for this (e.g.: inline_checkbox)
boolean_style is configured as :nested by default, I think:
# Defaults to :nested for bootstrap config.
# :inline => input + label
# :nested => label > input
config.boolean_style = :nested
Found a solution after much Google fu.
Use input_field
instead of input
which won't automatically generate a label.
= f.input_field :remember_me, as: :boolean, inline_label: 'Remember me'
.control-group.error .help-inline {
display: none;
}
This should work, it works for me on rails 3.2 and simple_form 2.x+
Maybe too late, but inspired by gamov answer I have made this a custom wrapper from inline bootstrap checkbox in the initializer file 'config/simple_form_bootstrap.rb':
config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.optional :readonly
b.use :label, class: 'col-sm-3 control-label'
b.use :input
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
which generates this html:
<div class="form-group boolean optional user_admin">
<label class="boolean optional col-sm-3 control-label" for="user_admin">Admin</label>
<div class="col-sm-9 checkbox-inline">
<input name="user[admin]" value="0" type="hidden">
<input class="boolean optional" id="user_admin" name="user[admin]" value="1" type="checkbox">
</div>
You can use:
= f.input :remember_me, as: :boolean, inline_label: 'Remember me', label: false