Class: TaoForm::Components::RadioButtonComponent

Inherits:
FieldComponent
  • Object
show all
Defined in:
lib/tao_form/components/radio_button_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 = nil, attribute_name = nil, options = {}) ⇒ RadioButtonComponent

Returns a new instance of RadioButtonComponent.



7
8
9
10
11
12
13
14
15
# File 'lib/tao_form/components/radio_button_component.rb', line 7

def initialize view, builder = nil, attribute_name = nil, options = {}
  super view, builder, attribute_name, options
  @checked_value = @options.delete(:checked_value)
  @unchecked_value = @options.delete(:unchecked_value)
  @checked = @options.delete(:checked)
  @disabled = @options.delete(:disabled)

  init_field_options
end

Instance Attribute Details

#checkedObject (readonly)

Returns the value of attribute checked.



5
6
7
# File 'lib/tao_form/components/radio_button_component.rb', line 5

def checked
  @checked
end

#checked_valueObject (readonly)

Returns the value of attribute checked_value.



5
6
7
# File 'lib/tao_form/components/radio_button_component.rb', line 5

def checked_value
  @checked_value
end

#disabledObject (readonly)

Returns the value of attribute disabled.



5
6
7
# File 'lib/tao_form/components/radio_button_component.rb', line 5

def disabled
  @disabled
end

#field_optionsObject (readonly)

Returns the value of attribute field_options.



5
6
7
# File 'lib/tao_form/components/radio_button_component.rb', line 5

def field_options
  @field_options
end

#unchecked_valueObject (readonly)

Returns the value of attribute unchecked_value.



5
6
7
# File 'lib/tao_form/components/radio_button_component.rb', line 5

def unchecked_value
  @unchecked_value
end

Class Method Details

.component_nameObject



17
18
19
# File 'lib/tao_form/components/radio_button_component.rb', line 17

def self.component_name
  :radio_button
end

Instance Method Details

#render(&block) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tao_form/components/radio_button_component.rb', line 21

def render &block
  if block_given?
    super
  elsif builder && attribute_name
    super {
      builder.radio_button attribute_name, field_options, checked_value, unchecked_value
    }
  else
    super {
      view.radio_button_tag nil
    }
  end
end