Class: FieldErrorTag

Inherits:
LiquidumTag
  • Object
show all
Defined in:
lib/scribo/liquid/tags/field_error_tag.rb

Overview

Add errors for a specific form field, only works inside a form

Basic usage:

{%field_error name%}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#field_typeObject

Returns the value of attribute field_type.



9
10
11
# File 'lib/scribo/liquid/tags/field_error_tag.rb', line 9

def field_type
  @field_type
end

Instance Method Details

#render(context) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/scribo/liquid/tags/field_error_tag.rb', line 11

def render(context)
  super

  error_messages = lookup(context, "form.errors.messages.#{argv1}")

  if error_messages.present?
    result = %[<span>] +
             attr_str(:class, arg(:class), input(:class, argv1)) +
             (error_messages || []).join(', ') + %[</span>]
  end

  result
end