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

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

Direct Known Subclasses

MultipleResultComponent

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 = {}, html_options) ⇒ ResultComponent

Returns a new instance of ResultComponent.



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

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

  if @html_options[:class].present?
    @html_options[:class] += " select-result"
  else
    @html_options[:class] = "select-result"
  end
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

#html_optionsObject (readonly)

Returns the value of attribute html_options.



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

def html_options
  @html_options
end

Class Method Details

.component_nameObject



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

def self.component_name
  :select_result
end

Instance Method Details

#render(&block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/tao_form/components/select/result_component.rb', line 20

def render &block
  if block_given?
    super
  else
    super {builder.select attribute_name, choices, options}
  end
end