Class: PhlexKit::RadioButton

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

Overview

Single radio input. Ported from ruby_ui's RubyUI::RadioButton. Registers as a phlex-kit--form-field input target, so it live-validates inside a PhlexKit::FormField (Stimulus ignores the wiring otherwise).

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(**attrs) ⇒ RadioButton

Returns a new instance of RadioButton.



6
# File 'app/components/phlex_kit/radio_button/radio_button.rb', line 6

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

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
16
17
# File 'app/components/phlex_kit/radio_button/radio_button.rb', line 8

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