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.
|
# Needs to be enabled in order to do automatic lookups.
|
||||||
module Hints
|
module Hints
|
||||||
def hint
|
def hint
|
||||||
if options[:hint] == true
|
@hint ||= if options[:hint] == true
|
||||||
translate(:hints)
|
translate(:hints)
|
||||||
else
|
else
|
||||||
options[:hint]
|
options[:hint]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_hint?
|
||||||
|
hint.present?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ module SimpleForm
|
||||||
css = options[:wrapper_class] ? Array.wrap(options[:wrapper_class]) : @defaults[:class]
|
css = options[:wrapper_class] ? Array.wrap(options[:wrapper_class]) : @defaults[:class]
|
||||||
css += input.html_classes
|
css += input.html_classes
|
||||||
css << (options[:wrapper_error_class] || @defaults[:error_class]) if input.has_errors?
|
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
|
css
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue