From caca9457266fdbc8243c2b9ba8de37e64409c58a Mon Sep 17 00:00:00 2001 From: Erich Kist Date: Sat, 23 Nov 2013 11:30:28 -0200 Subject: [PATCH 1/4] Add to REAME some doc to boolean_style --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 7b3dbcab..a5c16518 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 want to 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 From d01f3e261c69b09556a63016251af1a9d29ad776 Mon Sep 17 00:00:00 2001 From: Erich Kist Date: Sat, 23 Nov 2013 11:41:34 -0200 Subject: [PATCH 2/4] Fix grammar --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5c16518..741d2aad 100644 --- a/README.md +++ b/README.md @@ -263,7 +263,7 @@ end ``` -For check boxes and radio buttons you can want to remove the label changing `boolean_style` from defaul value `:nested` to `:inline`. +For check boxes and radio buttons you can remove the label changing `boolean_style` from defaul value `:nested` to `:inline`. Example: From eb5b63cd460778e639c0f109eb20a24503be7b58 Mon Sep 17 00:00:00 2001 From: Lucas Mazza Date: Tue, 10 Dec 2013 14:29:37 -0200 Subject: [PATCH 3/4] Don't render the `boolean_style` as an HTML attribute on `input_field`. --- README.md | 2 +- lib/simple_form/form_builder.rb | 2 +- test/form_builder/input_field_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 741d2aad..f8273e36 100644 --- a/README.md +++ b/README.md @@ -279,7 +279,7 @@ end ... - + ``` diff --git a/lib/simple_form/form_builder.rb b/lib/simple_form/form_builder.rb index 44ae509e..420c44aa 100644 --- a/lib/simple_form/form_builder.rb +++ b/lib/simple_form/form_builder.rb @@ -137,7 +137,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 SimpleForm::Wrappers::Root.new(ATTRIBUTE_COMPONENTS + [:input], wrapper: false).render find_input(attribute_name, options) diff --git a/test/form_builder/input_field_test.rb b/test/form_builder/input_field_test.rb index 755ad85b..bccd28a3 100644 --- a/test/form_builder/input_field_test.rb +++ b/test/form_builder/input_field_test.rb @@ -122,4 +122,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 From a30935a55b73b966cadd1d2255bb8c114af3137f Mon Sep 17 00:00:00 2001 From: Erich Kist Date: Tue, 10 Dec 2013 18:12:39 -0200 Subject: [PATCH 4/4] Update hash syntax --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f8273e36..e90aac7b 100644 --- a/README.md +++ b/README.md @@ -248,7 +248,7 @@ Example: ```ruby simple_form_for @user do |f| f.input_field :name - f.input_field :remember_me, :as => :boolean + f.input_field :remember_me, as: :boolean end ``` @@ -270,7 +270,7 @@ Example: ```ruby simple_form_for @user do |f| f.input_field :name - f.input_field :remember_me, :as => :boolean, boolean_style: :inline + f.input_field :remember_me, as: :boolean, boolean_style: :inline end ```