Class: Primer::Forms::Select
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Primer::Forms::Select
- Defined in:
- app/lib/primer/forms/select.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#initialize(input:) ⇒ Select
constructor
A new instance of Select.
- #options ⇒ Object
Methods inherited from BaseComponent
compile!, #content, #input?, #perform_render, #render?, #to_component, #type
Methods included from ActsAsComponent
#compile!, extended, #renders_templates
Methods included from ClassNameHelper
Constructor Details
#initialize(input:) ⇒ Select
Returns a new instance of Select.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/lib/primer/forms/select.rb', line 9 def initialize(input:) @input = input @input.add_input_classes("FormControl-select") if !input.multiple? @input.add_input_classes( Primer::Forms::Dsl::Input::SIZE_MAPPINGS[@input.size] ) end wrap_classes = ["FormControl-select-wrap"] wrap_classes << Primer::Forms::Dsl::Input::INPUT_WIDTH_MAPPINGS[@input.input_width] if @input.input_width @field_wrap_arguments = { class: class_names(wrap_classes), hidden: @input.hidden?, data: { multiple: input.multiple? } } end |
Instance Method Details
#options ⇒ Object
29 30 31 32 33 |
# File 'app/lib/primer/forms/select.rb', line 29 def @options ||= @input..map do |option| [option.label, option.value, option.system_arguments] end end |