@@ -13,7 +13,7 @@ def check_box_with_bootstrap(name, options={}, checked_value="1", unchecked_valu
1313 content = tag . div ( class : check_box_wrapper_class ( options ) , **options [ :wrapper ] . to_h . except ( :class ) ) do
1414 html = check_box_without_bootstrap ( name , check_box_options ( name , options ) , checked_value , unchecked_value )
1515 html << check_box_label ( name , options , checked_value , &block ) unless options [ :skip_label ]
16- html << generate_error ( name ) if options [ :error_message ]
16+ html << generate_error ( name , options [ :id ] ) if options [ :error_message ]
1717 html
1818 end
1919 wrapper ( content , options )
@@ -41,7 +41,10 @@ def check_box_options(name, options)
4141 :inline , :label , :label_class , :label_col , :layout , :skip_label ,
4242 :switch , :wrapper , :wrapper_class )
4343 check_box_options [ :class ] = check_box_classes ( name , options )
44- check_box_options [ :aria ] = { labelledby : field_id ( name , :feedback ) } if error? ( name )
44+ if error? ( name )
45+ labelledby = options [ :id ] . present? ? "#{ options [ :id ] } _feedback" : field_id ( name , :feedback )
46+ check_box_options [ :aria ] = { labelledby : }
47+ end
4548 check_box_options . merge! ( required_field_options ( options , name ) )
4649 end
4750
0 commit comments