Skip to content

Commit

Permalink
Added error notification class and id as configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
butsjoh authored and josevalim committed Nov 7, 2010
1 parent 5c1db60 commit 693153d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/generators/simple_form/templates/simple_form.rb
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions lib/simple_form.rb
Expand Up @@ -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 ]
Expand Down
4 changes: 3 additions & 1 deletion lib/simple_form/error_notification.rb
Expand Up @@ -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

Expand Down

0 comments on commit 693153d

Please sign in to comment.