Use similar api for hints and errors, and cache hint to avoid double lookup
This commit is contained in:
parent
0bca82c419
commit
d719e47c18
|
@ -3,12 +3,16 @@ module SimpleForm
|
|||
# Needs to be enabled in order to do automatic lookups.
|
||||
module Hints
|
||||
def hint
|
||||
if options[:hint] == true
|
||||
@hint ||= if options[:hint] == true
|
||||
translate(:hints)
|
||||
else
|
||||
options[:hint]
|
||||
end
|
||||
end
|
||||
|
||||
def has_hint?
|
||||
hint.present?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ module SimpleForm
|
|||
css = options[:wrapper_class] ? Array.wrap(options[:wrapper_class]) : @defaults[:class]
|
||||
css += input.html_classes
|
||||
css << (options[:wrapper_error_class] || @defaults[:error_class]) if input.has_errors?
|
||||
css << (options[:wrapper_hint_class] || @defaults[:hint_class]) if input.hint
|
||||
css << (options[:wrapper_hint_class] || @defaults[:hint_class]) if input.has_hint?
|
||||
css
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue