diff --git a/lib/generators/simple_form/templates/config/initializers/simple_form.rb.tt b/lib/generators/simple_form/templates/config/initializers/simple_form.rb.tt index 76df7b29..bc89e2d5 100644 --- a/lib/generators/simple_form/templates/config/initializers/simple_form.rb.tt +++ b/lib/generators/simple_form/templates/config/initializers/simple_form.rb.tt @@ -121,7 +121,7 @@ SimpleForm.setup do |config| # Define the way to render checkboxes with labels. Defaults to :inline. # :inline => input + label # :nested => label > input - # config.checkbox_style = :inline + # config.boolean_style = :inline # You can define the class to use on all forms. Default is simple_form. # config.form_class = :simple_form diff --git a/lib/simple_form.rb b/lib/simple_form.rb index d8ae1673..199e30f2 100644 --- a/lib/simple_form.rb +++ b/lib/simple_form.rb @@ -64,8 +64,8 @@ module SimpleForm # Define the way to render checkboxes with labels. Defaults to :inline. # :inline => input + label # :nested => label > input - mattr_accessor :checkbox_style - @@checkbox_style = :inline + mattr_accessor :boolean_style + @@boolean_style = :inline # You can define the class to use on all forms. Default is simple_form. mattr_accessor :form_class diff --git a/lib/simple_form/inputs/boolean_input.rb b/lib/simple_form/inputs/boolean_input.rb index 67e32be5..c9891ac4 100644 --- a/lib/simple_form/inputs/boolean_input.rb +++ b/lib/simple_form/inputs/boolean_input.rb @@ -18,7 +18,7 @@ module SimpleForm private def nested_style? - options[:checkbox_style] || SimpleForm.checkbox_style == :nested + options[:boolean_style] || SimpleForm.boolean_style == :nested end # Booleans are not required by default because in most of the cases diff --git a/test/inputs/boolean_input_test.rb b/test/inputs/boolean_input_test.rb index 0b9f5152..394ad9ed 100644 --- a/test/inputs/boolean_input_test.rb +++ b/test/inputs/boolean_input_test.rb @@ -14,28 +14,28 @@ class BooleanInputTest < ActionView::TestCase assert_no_select 'label' end - test 'input uses inline checkbox style by default' do + test 'input uses inline boolean style by default' do with_input_for @user, :active, :boolean assert_select 'input.boolean + label.boolean.optional' assert_no_select 'label > input' end - test 'input allows changing default checkbox style config to nested, generating a default label' do - swap SimpleForm, :checkbox_style => :nested do + test 'input allows changing default boolean style config to nested, generating a default label' do + swap SimpleForm, :boolean_style => :nested do with_input_for @user, :active, :boolean assert_select 'label > input.boolean' assert_no_select 'label.boolean' end end - test 'input accepts changing checkbox style through given options' do - with_input_for @user, :active, :boolean, :checkbox_style => :nested + test 'input accepts changing boolean style through given options' do + with_input_for @user, :active, :boolean, :boolean_style => :nested assert_select 'label > input.boolean' assert_no_select 'label.boolean' end test 'input with nested style allows disabling label' do - swap SimpleForm, :checkbox_style => :nested do + swap SimpleForm, :boolean_style => :nested do with_input_for @user, :active, :boolean, :label => false assert_select 'input.boolean' assert_no_select 'label'