Class: PhlexKit::SelectInput

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/select/select_input.rb

Overview

The hidden input that actually carries PhlexKit::Select's value into the form — the Stimulus controller writes the chosen item's value here and dispatches a change (which also feeds phlex-kit--form-field validation when the select sits inside a PhlexKit::FormField). Pass name:/id:/value: like any input; it's display:none. See select.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ SelectInput

Returns a new instance of SelectInput.



8
9
10
# File 'app/components/phlex_kit/select/select_input.rb', line 8

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

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
# File 'app/components/phlex_kit/select/select_input.rb', line 12

def view_template
  input(**mix({
    class: "pk-select-input",
    data: {
      phlex_kit__select_target: "input",
      phlex_kit__form_field_target: "input",
      action: "change->phlex-kit--form-field#onChange invalid->phlex-kit--form-field#onInvalid"
    }
  }, @attrs))
end