Class: Primer::Forms::Select

Inherits:
BaseComponent show all
Defined in:
app/lib/primer/forms/select.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from BaseComponent

#content, inherited, #input?, #perform_render, #render?, #to_component, #type

Methods included from ActsAsComponent

#base_template_path, #compile!, extended, #renders_templates, #template_root_path

Methods included from ClassNameHelper

#class_names

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
# 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

  @field_wrap_arguments = {
    class: "FormControl-select-wrap",
    hidden: @input.hidden?,
    data: { multiple: input.multiple? }
  }
end

Instance Method Details

#optionsObject



26
27
28
29
30
# File 'app/lib/primer/forms/select.rb', line 26

def options
  @options ||= @input.options.map do |option|
    [option.label, option.value, option.system_arguments]
  end
end