diff --git a/README.md b/README.md index bb3fb68b..d90a195e 100644 --- a/README.md +++ b/README.md @@ -248,9 +248,41 @@ Example: ```ruby simple_form_for @user do |f| f.input_field :name + f.input_field :remember_me, as: :boolean end ``` +```html +
+ ... + + + +
+``` + +For check boxes and radio buttons you can remove the label changing `boolean_style` from defaul value `:nested` to `:inline`. + +Example: + +```ruby +simple_form_for @user do |f| + f.input_field :name + f.input_field :remember_me, as: :boolean, boolean_style: :inline +end +``` + +```html +
+ ... + + + +
+``` + Produces: ```html diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index 94a0f5d5..94641f92 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -132,7 +132,7 @@ module SimpleForm # def input_field(attribute_name, options={}) options = options.dup - options[:input_html] = options.except(:as, :collection, :label_method, :value_method, *ATTRIBUTE_COMPONENTS) + options[:input_html] = options.except(:as, :boolean_style, :collection, :label_method, :value_method, *ATTRIBUTE_COMPONENTS) options = @defaults.deep_dup.deep_merge(options) if @defaults input = find_input(attribute_name, options) diff --git a/test/form_builder/input_field_test.rb b/test/form_builder/input_field_test.rb index 1f399c1e..0f21c695 100644 --- a/test/form_builder/input_field_test.rb +++ b/test/form_builder/input_field_test.rb @@ -138,4 +138,12 @@ class InputFieldTest < ActionView::TestCase assert_no_select 'select.status[label_method]' assert_no_select 'select.status[value_method]' end + + test 'build input_field does not treat "boolean_style" as an HTML attribute' do + with_concat_form_for(@user) do |f| + f.input_field :active, boolean_style: :nested + end + + assert_no_select 'input.boolean[boolean_style]' + end end