class Forme::ErrorHandler::AfterLegend

  1. lib/forme/transformers/error_handler.rb
Superclass: ErrorHandler

Methods

Public Instance

  1. call

Public Instance methods

call (tag, input)
[show source]
   # File lib/forme/transformers/error_handler.rb
51 def call(tag, input)
52   return super unless tag.is_a?(Array)
53   return super unless tag.first.is_a?(Tag)
54   return super unless tag.first.type == :legend
55 
56   first_input = input.opts[:first_input]
57   attr = first_input.opts[:attr] ||= {}
58   Forme.attr_classes(attr, 'error')
59   attr['aria-invalid'] = 'true'
60   attr['aria-describedby'] = input.opts[:error_id] = "#{first_input.opts[:id]}_error_message"
61 
62   tag.insert(1, error_tag(input))
63 end