Class: EnumRadioInput
- Inherits:
-
SimpleForm::Inputs::CollectionRadioButtonsInput
- Object
- SimpleForm::Inputs::CollectionRadioButtonsInput
- EnumRadioInput
- Defined in:
- app/inputs/enum_radio_input.rb
Overview
SimpleForm input wrapper: enum radio.
Direct Known Subclasses
Instance Method Summary collapse
- #collection ⇒ Object protected
-
#initialize(builder, attribute_name, column, input_type, options = {}) ⇒ EnumRadioInput
constructor
Renders an enum attribute as radio buttons, forcing
input_typeto:radio_buttons. - #input(wrapper_options = nil) ⇒ Object
Constructor Details
#initialize(builder, attribute_name, column, input_type, options = {}) ⇒ EnumRadioInput
Renders an enum attribute as radio buttons, forcing input_type to :radio_buttons.
The collection is built from the model's enum keys (see #collection).
15 16 17 18 |
# File 'app/inputs/enum_radio_input.rb', line 15 def initialize(builder, attribute_name, column, input_type, = {}) input_type = :radio_buttons super end |
Instance Method Details
#collection ⇒ Object (protected)
26 27 28 |
# File 'app/inputs/enum_radio_input.rb', line 26 def collection object.class.send(attribute_name.to_s.pluralize).keys.map { |k| [k.titleize, k] } end |
#input(wrapper_options = nil) ⇒ Object
20 21 22 |
# File 'app/inputs/enum_radio_input.rb', line 20 def input( = nil) super end |