diff --git a/lib/simple_form/components/hints.rb b/lib/simple_form/components/hints.rb index 80eded79..f743db8c 100644 --- a/lib/simple_form/components/hints.rb +++ b/lib/simple_form/components/hints.rb @@ -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 diff --git a/lib/simple_form/wrappers/root.rb b/lib/simple_form/wrappers/root.rb index 14d5ace0..ec3fa58f 100644 --- a/lib/simple_form/wrappers/root.rb +++ b/lib/simple_form/wrappers/root.rb @@ -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