Class: TaoForm::Components::Select::ResultComponent

Inherits:
FieldComponent
  • Object
show all
Defined in:
lib/tao_form/components/select/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 = {}) ⇒ ResultComponent

Returns a new instance of ResultComponent.



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

def initialize view, builder, attribute_name, choices = nil, options = {}
  super view, builder, attribute_name, options
  @choices = choices
  @placeholder = options.delete(:placeholder)

  init_field_options
end

Instance Attribute Details

#choicesObject (readonly)

Returns the value of attribute choices.



6
7
8
# File 'lib/tao_form/components/select/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/result_component.rb', line 6

def field_options
  @field_options
end

#placeholderObject (readonly)

Returns the value of attribute placeholder.



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

def placeholder
  @placeholder
end

Class Method Details

.component_nameObject



26
27
28
# File 'lib/tao_form/components/select/result_component.rb', line 26

def self.component_name
  :select_result
end

Instance Method Details

#render(&block) ⇒ Object



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

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