Sha256: 8a458f4ded08345daf7c33f24679aca8c44ffb4f5f3b0afa5e949774f5b5a742
Contents?: true
Size: 791 Bytes
Versions: 1
Compression:
Stored size: 791 Bytes
Contents
module Railsstrap module FormErrorsHelper include ActionView::Helpers::FormTagHelper #attr_reader required for Rails 3.2 support attr_reader :template attr_reader :object def error_span(attribute, options = {}) options[:span_class] ||= 'help-block' options[:error_class] ||= 'has-error' if errors_on?(attribute) @template.content_tag( :div, :class => options[:error_class] ) do content_tag( :span, errors_for(attribute), :class => options[:span_class] ) end end end def errors_on?(attribute) object.errors[attribute].present? if object.respond_to?(:errors) end def errors_for(attribute) object.errors[attribute].try(:join, ', ') || object.errors[attribute].try(:to_s) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
railsstrap-3.3.4 | app/helpers/railsstrap/form_errors_helper.rb |