diff --git a/lib/generators/simple_form/templates/simple_form.rb b/lib/generators/simple_form/templates/simple_form.rb index e30064277..27837f6f8 100644 --- a/lib/generators/simple_form/templates/simple_form.rb +++ b/lib/generators/simple_form/templates/simple_form.rb @@ -22,6 +22,12 @@ # Default tag used for error notification helper. # config.error_notification_tag = :p + # CSS class to add for error notification helper. + # config.error_notification_class = '' + + # ID to add for error notification helper. + # config.error_notification_id = '' + # You can wrap all inputs in a pre-defined tag. # config.wrapper_tag = :div diff --git a/lib/simple_form.rb b/lib/simple_form.rb index 7534dd40e..82c5eb16e 100644 --- a/lib/simple_form.rb +++ b/lib/simple_form.rb @@ -35,6 +35,14 @@ module SimpleForm mattr_accessor :error_notification_tag @@error_notification_tag = :p + # CSS class to add for error notification helper. + mattr_accessor :error_notification_class + @@error_notification_class = nil + + # ID to add for error notification helper. + mattr_accessor :error_notification_id + @@error_notification_id = nil + # Components used by the form builder. mattr_accessor :components @@components = [ :label_input, :hint, :error ] diff --git a/lib/simple_form/error_notification.rb b/lib/simple_form/error_notification.rb index 5a9869e14..b7f40967a 100644 --- a/lib/simple_form/error_notification.rb +++ b/lib/simple_form/error_notification.rb @@ -26,7 +26,9 @@ def error_notification_tag end def html_options - @options[:class] = "error_notification #{@options[:class]}".strip + css_class = SimpleForm.error_notification_class || @options[:class] + @options[:class] = "error_notification #{css_class}".strip + @options[:id] = SimpleForm.error_notification_id if SimpleForm.error_notification_id @options end