Class: UU::OS::Form::Radio

Inherits:
Input show all
Defined in:
uu_os_gvc-0.28.16/lib/uu/os/form/radio.rb

Overview

Radio component.

Instance Attribute Summary (collapse)

Attributes inherited from Input

#data, #disabled, #read_only, #required, #submit_value_change, #value, #value_change_action_uri, #width

Attributes inherited from GVC::Component

#attributes, #code, #component_type, #form, #height, #id, #name, #width

Instance Method Summary (collapse)

Methods inherited from GVC::Component

#add_message, #focus, #initialize, #messages

Constructor Details

This class inherits a constructor from UU::OS::GVC::Component

Instance Attribute Details

- (Object) group

The group that this radio button belongs to.



11
12
13
# File 'uu_os_gvc-0.28.16/lib/uu/os/form/radio.rb', line 11

def group
  @group
end

- (Object) text

The text (label) of the radio button.



14
15
16
# File 'uu_os_gvc-0.28.16/lib/uu/os/form/radio.rb', line 14

def text
  @text
end

Instance Method Details

- (Object) value=(value)



32
33
34
35
36
37
38
39
40
41
42
43
# File 'uu_os_gvc-0.28.16/lib/uu/os/form/radio.rb', line 32

def value=(value)
  attributes[:value] = value

  if value == 'true' || value.kind_of?(TrueClass)
    # set other radio-s in the same group to false
    @container.components.select do |comp|
      comp.component_type == component_type && comp.group == group && comp != self
    end.each do |radio|
      radio.value = false
    end
  end
end