Class: SegmentedControlInput
- Inherits:
-
SimpleForm::Inputs::CollectionRadioButtonsInput
- Object
- SimpleForm::Inputs::CollectionRadioButtonsInput
- SegmentedControlInput
- Defined in:
- lib/generators/rolemodel/simple_form/templates/app/inputs/segmented_control_input.rb
Overview
SegmentedControlInput is a custom input type for SimpleForm that renders a radio group as an optics (v2.2.0+) segmented control
Options:
:size (:small, :medium, :large) - renders the control at different sizes
:full_width - renders the control to take the full width of its container
Usage: <%= f.input :my_field, as: :segmented_control, collection: collection_options %> <%= f.input :my_field, as: :segmented_control, collection: collection_options, size: :small %> <%= f.input :my_field, as: :segmented_control, collection: collection_options, disabled: true %> <%= f.input :my_field, as: :segmented_control, collection: collection_options, full_width: true %>
Instance Method Summary collapse
- #input_html_classes ⇒ Object
- #input_html_options ⇒ Object
- #input_options ⇒ Object
- #input_type ⇒ Object
Instance Method Details
#input_html_classes ⇒ Object
34 35 36 |
# File 'lib/generators/rolemodel/simple_form/templates/app/inputs/segmented_control_input.rb', line 34 def input_html_classes super.push('segmented-control__input') end |
#input_html_options ⇒ Object
28 29 30 31 32 |
# File 'lib/generators/rolemodel/simple_form/templates/app/inputs/segmented_control_input.rb', line 28 def super.tap do || [:class].delete('form-control') end end |
#input_options ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/generators/rolemodel/simple_form/templates/app/inputs/segmented_control_input.rb', line 19 def = super [:item_wrapper_tag] = false [:collection_wrapper_tag] = 'div' [:collection_wrapper_class] = collection_wrapper_classes [:item_label_class] = 'segmented-control__label' end |
#input_type ⇒ Object
15 16 17 |
# File 'lib/generators/rolemodel/simple_form/templates/app/inputs/segmented_control_input.rb', line 15 def input_type 'radio_buttons' end |