Added error notification class and id as configuration option

This commit is contained in:
Johan Buts 2010-10-18 21:21:19 +08:00 committed by José Valim
parent 5c1db60dfd
commit 693153d169
3 changed files with 17 additions and 1 deletions

View File

@ -22,6 +22,12 @@ SimpleForm.setup do |config|
# 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

View File

@ -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 ]

View File

@ -26,7 +26,9 @@ module SimpleForm
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