Class: FormProps::Inputs::Select
- Includes:
- FormOptionsHelper
- Defined in:
- lib/form_props/inputs/select.rb
Instance Method Summary collapse
-
#initialize(object_name, method_name, template_object, choices, options, html_options) ⇒ Select
constructor
A new instance of Select.
- #render ⇒ Object
Methods included from FormOptionsHelper
#extract_selected_and_disabled, #extract_values_from_collection, #grouped_options_for_select, #option_groups_from_collection_for_select, #option_html_attributes, #options_for_select, #options_from_collection_for_select, #selected_values, #time_zone_options_for_select, #value_for_collection, #weekday_options_for_select
Methods inherited from Base
Constructor Details
#initialize(object_name, method_name, template_object, choices, options, html_options) ⇒ Select
Returns a new instance of Select.
8 9 10 11 12 13 14 |
# File 'lib/form_props/inputs/select.rb', line 8 def initialize(object_name, method_name, template_object, choices, , ) @choices = choices @choices = @choices.to_a if @choices.is_a?(Range) @html_options = super(object_name, method_name, template_object, ) end |
Instance Method Details
#render ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/form_props/inputs/select.rb', line 16 def render = { selected: @options.fetch(:selected) { value.nil? ? "" : value }, disabled: @options[:disabled] } = if grouped_choices? (@choices, ) else (@choices, ) end select_content_props(, @options, @html_options) end |