Class: TaoForm::Components::Select::MultipleResultComponent

Inherits:
FieldComponent
  • Object
show all
Defined in:
lib/tao_form/components/select/multiple_result_component.rb

Instance Attribute Summary collapse

Attributes inherited from FieldComponent

#attribute_name, #builder

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, builder, attribute_name, choices = nil, options = {}) ⇒ MultipleResultComponent

Returns a new instance of MultipleResultComponent.



8
9
10
11
12
13
# File 'lib/tao_form/components/select/multiple_result_component.rb', line 8

def initialize view, builder, attribute_name, choices = nil, options = {}
  super view, builder, attribute_name, options
  @choices = choices

  init_field_options
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



6
7
8
# File 'lib/tao_form/components/select/multiple_result_component.rb', line 6

def choices
  @choices
end

#field_optionsObject (readonly)

Returns the value of attribute field_options.



6
7
8
# File 'lib/tao_form/components/select/multiple_result_component.rb', line 6

def field_options
  @field_options
end

Class Method Details

.component_nameObject



28
29
30
# File 'lib/tao_form/components/select/multiple_result_component.rb', line 28

def self.component_name
  :multiple_select_result
end

Instance Method Details

#render(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tao_form/components/select/multiple_result_component.rb', line 15

def render &block
  if block_given?
    super
  elsif builder && attribute_name
    super {
      builder.select attribute_name, choices, field_options, {
        disabled: options[:disabled],
        multiple: true
      }
    }
  end
end