Sha256: 02f39c80830aa891185f175bc014bf0f98f2731b89d3218254c015b0b76e947a

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

module Storefront
  class Form
    class Errors < Storefront::Form::Base
      def initialize(options = {})
        super
        
        attributes.merge!(options[:error_html]) if options[:error_html]
        attributes.delete :error_html
        attributes.delete :error
        # error
        merge_class! @attributes, config.error_class
        # aria-invalid = true|grammar|spelling
        # aria-hidden
        attributes[:id]  ||= attribute.to_id(:type => :error, :index => index, :parent_index => parent_index) if config.id_enabled_on.include?("error")
        @value = model.errors_for(attribute.name)
      end
      
      def render(&block)
        template.capture_haml do
          if value.present?
            template.haml_tag config.error_tag, attributes do
              template.haml_concat value.join("\n").html_safe.gsub(/\n$/)
            end
          elsif config.always_include_error_tag
            template.haml_tag config.error_tag, attributes
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storefront-0.3.2 lib/storefront/form/errors.rb
storefront-0.3.1 lib/storefront/form/errors.rb
storefront-0.3.0 lib/storefront/form/errors.rb
storefront-0.2.8 lib/storefront/form/errors.rb
storefront-0.2.7 lib/storefront/form/errors.rb