Class: PhlexKit::FormFieldHint
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::FormFieldHint
- Defined in:
- app/components/phlex_kit/form_field/form_field_hint.rb
Overview
Muted helper text under a PhlexKit::FormField control. Hidden when empty. See form_field.rb.
Instance Method Summary collapse
-
#initialize(id: nil, **attrs) ⇒ FormFieldHint
constructor
A default id (like FormFieldError) so the controller can wire the hint into every control's aria-describedby — without it SR users never heard the hint text.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(id: nil, **attrs) ⇒ FormFieldHint
A default id (like FormFieldError) so the controller can wire the hint into every control's aria-describedby — without it SR users never heard the hint text. id: is a named kwarg to avoid mix id-fusion.
8 9 10 11 |
# File 'app/components/phlex_kit/form_field/form_field_hint.rb', line 8 def initialize(id: nil, **attrs) @id = id || "pk-form-field-hint-#{SecureRandom.hex(4)}" @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
13 14 15 |
# File 'app/components/phlex_kit/form_field/form_field_hint.rb', line 13 def view_template(&block) p(**mix({ id: @id, class: "pk-form-field-hint", data: { phlex_kit__form_field_target: "hint" } }, @attrs), &block) end |