module Formular::Element::Modules::Error::InstanceMethods
options functionality (same as SimpleForm): options == false NO ERROR regardless of model errors options == String return the string, regardless of model errors
Public Instance Methods
error_text()
click to toggle source
# File lib/formular/element/modules/error.rb, line 16 def error_text return unless has_errors? text = has_custom_error? ? options[:error] : errors_on_attribute.send(error_method) html_escape(text) end
has_errors?()
click to toggle source
# File lib/formular/element/modules/error.rb, line 23 def has_errors? options[:error] != false && (has_custom_error? || has_attribute_errors?) end
Protected Instance Methods
error_method()
click to toggle source
attribute_errors is an array, what method should we use to return a string? (:first, :last, :join etc.) ideally this should be configurable via the builder…
# File lib/formular/element/modules/error.rb, line 32 def error_method :first end
errors_on_attribute()
click to toggle source
# File lib/formular/element/modules/error.rb, line 46 def errors_on_attribute @errors ||= builder.errors[options[:attribute_name]] end
has_attribute_errors?()
click to toggle source
I bet we could clean this up alot but it needs to be flexible enough not to error with nils
# File lib/formular/element/modules/error.rb, line 38 def has_attribute_errors? builder != nil && builder.errors != nil && errors_on_attribute != nil && errors_on_attribute.size > 0 end
has_custom_error?()
click to toggle source
# File lib/formular/element/modules/error.rb, line 42 def has_custom_error? options[:error].is_a?(String) end