File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,9 @@ def html_options(options)
6767 end
6868
6969 def html_classes ( input , options )
70- @defaults [ :class ] . dup
70+ css = @defaults [ :class ] . dup
71+ css << @defaults [ :error_class ] . dup { input . has_errors? }
72+ css . compact
7173 end
7274 end
7375 end
Original file line number Diff line number Diff line change @@ -375,4 +375,11 @@ class WrapperTest < ActionView::TestCase
375375 assert_no_select 'p.omg_hint'
376376 end
377377 end
378+
379+ test 'inline wrapper has an error class' do
380+ swap_wrapper :default , custom_wrapper_with_error_class do
381+ with_form_for @user , :name
382+ assert_select 'section.custom_wrapper div.custom_error'
383+ end
384+ end
378385end
Original file line number Diff line number Diff line change @@ -85,6 +85,14 @@ def custom_wrapper_with_unless_blank
8585 end
8686 end
8787
88+ def custom_wrapper_with_error_class
89+ SimpleForm . build tag : :section , class : "custom_wrapper" do |b |
90+ b . wrapper tag : :div , error_class : 'custom_error' do |ba |
91+ ba . optional :hint , wrap_with : { tag : :p , class : 'omg_hint' }
92+ end
93+ end
94+ end
95+
8896 def custom_wrapper_with_input_class
8997 SimpleForm . build tag : :div , class : "custom_wrapper" do |b |
9098 b . use :label
You can’t perform that action at this time.
0 commit comments