Sha256: ce5262a3bdda4e8d4a40072bfc5f9bf3a181a2e5eb34387ccba3b92bd7ac33db
Contents?: true
Size: 742 Bytes
Versions: 5
Compression:
Stored size: 742 Bytes
Contents
module Railsstrap module FormErrorsHelper include ActionView::Helpers::FormTagHelper 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
5 entries across 5 versions & 1 rubygems