Class: Phlexi::Form::Components::CollectionRadioButtons
- Includes:
- Phlexi::Form::Components::Concerns::AcceptsChoices, Phlexi::Form::Components::Concerns::HandlesInput
- Defined in:
- lib/phlexi/form/components/collection_radio_buttons.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from Phlexi::Form::Components::Concerns::ExtractsInput
Methods inherited from Base
Constructor Details
This class inherits a constructor from Phlexi::Form::Components::Base
Instance Method Details
#view_template ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/phlexi/form/components/collection_radio_buttons.rb', line 10 def view_template div(**attributes.slice(:id, :class)) do field.repeated(choices.values) do |builder| render builder.hidden_field_tag if builder.index == 0 field = builder.field( label: choices[builder.key], # We set the attributes here so they are applied to all input components even if the user decides to use a block input_attributes: { checked_value: builder.key, checked: selected?(builder.key) } ) if block_given? yield field else render field. render field.label_tag end end end end |