diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 6b771058..eb9c057d 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,3 +1,6 @@ +* enhancements + * Add error class on wrappers (by github.com/jduff) + == 1.2.0 * deprecation diff --git a/lib/generators/simple_form/templates/simple_form.rb b/lib/generators/simple_form/templates/simple_form.rb index 499c6ace..97ce12d7 100644 --- a/lib/generators/simple_form/templates/simple_form.rb +++ b/lib/generators/simple_form/templates/simple_form.rb @@ -17,7 +17,7 @@ SimpleForm.setup do |config| # config.wrapper_tag = :div # CSS class to add to the wrapper if the field has errors - # config.wrapper_errors_class = :fieldWithErrors + # config.wrapper_error_class = :fieldWithErrors # How the label text should be generated altogether with the required text. # config.label_text = lambda { |label, required| "#{required} #{label}" } diff --git a/lib/simple_form.rb b/lib/simple_form.rb index 893566c1..f31b6321 100644 --- a/lib/simple_form.rb +++ b/lib/simple_form.rb @@ -33,8 +33,8 @@ module SimpleForm mattr_accessor :wrapper_tag @@wrapper_tag = :div - mattr_accessor :wrapper_errors_class - @@wrapper_errors_class = :fieldWithErrors + mattr_accessor :wrapper_error_class + @@wrapper_error_class = :fieldWithErrors # How the label text should be generated altogether with the required text. mattr_accessor :label_text diff --git a/lib/simple_form/components/wrapper.rb b/lib/simple_form/components/wrapper.rb index 2b75385a..43b261c6 100644 --- a/lib/simple_form/components/wrapper.rb +++ b/lib/simple_form/components/wrapper.rb @@ -14,7 +14,7 @@ module SimpleForm end def errors_class - options[:wrapper_errors_class] || SimpleForm.wrapper_errors_class + options[:wrapper_error_class] || SimpleForm.wrapper_error_class end def wrapper_html_options diff --git a/test/components/wrapper_test.rb b/test/components/wrapper_test.rb index 7002d491..9c1fcede 100644 --- a/test/components/wrapper_test.rb +++ b/test/components/wrapper_test.rb @@ -22,4 +22,11 @@ class WrapperTest < ActionView::TestCase with_error_for @user, :name assert_select 'div.fieldWithErrors' end + + test 'wrapper should add chosen error class for attribute with errors' do + swap SimpleForm, :wrapper_error_class => "omgError" do + with_error_for @user, :name + assert_select 'div.omgError' + end + end end