Module: GenericFormFor::Inputs::Base::ErrorMessage
- Included in:
- GenericFormFor::Inputs::Base
- Defined in:
- lib/generic_form_for/inputs/base/error_message.rb
Instance Method Summary collapse
- #error_html(config_options = {}) ⇒ Object
- #error_html_options(config_options = {}) ⇒ Object
- #errors ⇒ Object
- #errors? ⇒ Boolean
- #render_error? ⇒ Boolean
Instance Method Details
#error_html(config_options = {}) ⇒ Object
6 7 8 |
# File 'lib/generic_form_for/inputs/base/error_message.rb', line 6 def error_html(={}) template.concat(render_error? ? template.content_tag(:span, errors.join(", "), ()) : "") end |
#error_html_options(config_options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/generic_form_for/inputs/base/error_message.rb', line 10 def (={}) opts = ([:error_html] || {}).dup opts[:class] = ["error", *opts[:class], *[:class]].compact.join(' ').strip .merge(opts) end |
#errors ⇒ Object
16 17 18 |
# File 'lib/generic_form_for/inputs/base/error_message.rb', line 16 def errors @errors ||= object.respond_to?(:errors) ? object.errors[method.to_s] : [] end |
#errors? ⇒ Boolean
20 21 22 |
# File 'lib/generic_form_for/inputs/base/error_message.rb', line 20 def errors? !errors.empty? end |
#render_error? ⇒ Boolean
24 25 26 |
# File 'lib/generic_form_for/inputs/base/error_message.rb', line 24 def render_error? errors? end |