Sha256: a8543b57766b1cf8ec6f27a8830f84919bba997b27b18e81c54bbb66d43a465d

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 Bytes

Contents

module GenericFormFor
  module Inputs
    module Base
      module ErrorMessage
        
        def error_html(config_options={})
          template.concat(render_error? ? template.content_tag(:span, errors.join(", "), error_html_options(config_options)) : "")
        end
        
        def error_html_options(config_options={})
          opts = (options[:error_html] || {}).dup
          opts[:class] = ["error", *opts[:class], *config_options[:class]].compact.join(' ').strip   
          config_options.merge(opts)
        end
        
        def errors
          @errors ||= object.respond_to?(:errors) ? object.errors[method.to_s] : []
        end
        
        def errors?
          !errors.empty?
        end
        
        def render_error?
          errors?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
generic_form_for-0.0.1 lib/generic_form_for/inputs/base/error_message.rb