Class: Proscenium::UI::Form::Fields::RadioGroup
- Defined in:
- lib/proscenium/ui/form/fields/radio_group.rb
Overview
Render a group of <radio> inputs for the given model attribute. It supports ActiveRecord associations and enums.
## Supported options
-
options [Array] a list of options where each will render a radio input. If this is given, the
automatic detection of options will be disabled. A flat array of strings will be used for both the label and value. While an Array of nested two-level arrays will be used.
Instance Attribute Summary
Attributes inherited from Base
#attribute, #attributes, #form, #model
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Proscenium::UI::Form::Fields::Base
Instance Method Details
#before_template ⇒ Object
15 16 17 18 19 |
# File 'lib/proscenium/ui/form/fields/radio_group.rb', line 15 def before_template @options_from_attributes = attributes.delete(:options) super end |
#view_template ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/proscenium/ui/form/fields/radio_group.rb', line 21 def view_template field :pui_radio_group do label div part: :radio_group_inputs do .each do |opt| form.radio_input(*attribute, name: field_name, value: opt[:value], label: opt[:label], checked: opt[:checked], **attributes) end end hint end end |