class Forme::ErrorHandler

Default error handler used by the library, using an “error” class for the input field and a span tag with an “error_message” class for the error message.

Registered as :default.

Public Instance Methods

call(tag, input) click to toggle source

Return tag with error message span tag after it.

   # File lib/forme/transformers/error_handler.rb
13 def call(tag, input)
14   [tag, error_tag(input)]
15 end

Private Instance Methods

error_tag(input) click to toggle source
   # File lib/forme/transformers/error_handler.rb
19 def error_tag(input)
20   attr = input.opts[:error_attr]
21   attr = attr ? attr.dup : {}
22   Forme.attr_classes(attr, 'error_message')
23 
24   if id = input.opts[:error_id]
25     unless attr['id'] || attr[:id]
26       attr['id'] = id
27     end
28   end
29 
30   input.tag(:span, attr, input.opts[:error])
31 end