Class: Superform::Rails::Components::Radio
- Defined in:
- lib/superform/rails/components/radio.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #field_attributes ⇒ Object
-
#initialize(field, value:, index: value, **attributes) ⇒ Radio
constructor
A new instance of Radio.
- #view_template ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(field, value:, index: value, **attributes) ⇒ Radio
Returns a new instance of Radio.
5 6 7 8 9 |
# File 'lib/superform/rails/components/radio.rb', line 5 def initialize(field, value:, index: value, **attributes) super(field, **attributes) @value = value @index = index end |
Instance Method Details
#field_attributes ⇒ Object
15 16 17 |
# File 'lib/superform/rails/components/radio.rb', line 15 def field_attributes { id: DOM.join(dom.id, @index), name: dom.name, value: @value, checked: field.value == @value } end |
#view_template ⇒ Object
11 12 13 |
# File 'lib/superform/rails/components/radio.rb', line 11 def view_template(&) input(type: :radio, **attributes) end |