Class: Fluxbit::Form::SelectComponent
- Inherits:
-
TextFieldComponent
- Object
- TextFieldComponent
- Fluxbit::Form::SelectComponent
- Defined in:
- app/components/fluxbit/form/select_component.rb
Overview
The ‘Fluxbit::Form::SelectComponent` is a styled dropdown/select field for forms. It supports standard, grouped, and time zone options, integrates with Rails form builders, and provides flexible props for prompt, disabled/selected options, helper text, and more.
Instance Method Summary collapse
- #build_options_for_select ⇒ Object
-
#initialize(**props) ⇒ SelectComponent
constructor
Initializes the select component with the given properties.
- #input ⇒ Object
Constructor Details
#initialize(**props) ⇒ SelectComponent
Initializes the select component with the given properties.
25 26 27 28 29 30 31 32 33 |
# File 'app/components/fluxbit/form/select_component.rb', line 25 def initialize(**props) super(**props) @grouped = @props.delete(:grouped) || false @time_zone = @props.delete(:time_zone) || false @select_options = @props.delete(:select_options) || {} @choices = @props.delete(:choices) || nil @options = @props.delete(:options) || {} @options = ::ActiveSupport::TimeZone.all if @time_zone end |
Instance Method Details
#build_options_for_select ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/components/fluxbit/form/select_component.rb', line 52 def if @grouped ( @options, @selected, disabled: @disabled_options, prompt: @prompt, divider: @divider ) elsif @time_zone (@selected) else (@options, selected: @selected, disabled: @disabled_options) end end |
#input ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/fluxbit/form/select_component.rb', line 35 def input if @form.present? && @attribute.present? @form.select( @attribute, , @select_options, @props ) else select_tag( @name, , @props ) end end |