Class: PhlexKit::FormFieldError

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/form_field/form_field_error.rb

Overview

Validation error text for a PhlexKit::FormField, styled with the destructive token and hidden when empty. Render it empty for live client-side messages (the phlex-kit--form-field controller fills it once the control goes invalid), or with server-rendered model errors — non-empty content arms validation on connect. See form_field.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ FormFieldError

Returns a new instance of FormFieldError.



8
9
10
# File 'app/components/phlex_kit/form_field/form_field_error.rb', line 8

def initialize(**attrs)
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



12
13
14
15
16
17
# File 'app/components/phlex_kit/form_field/form_field_error.rb', line 12

def view_template(&block)
  p(**mix({
    class: "pk-form-field-error",
    data: { phlex_kit__form_field_target: "error" }
  }, @attrs), &block)
end