Class: Aurita::GUI::Select_Field

Inherits:
Options_Field show all
Defined in:
lib/aurita-gui/form/select_field.rb

Instance Attribute Summary

Attributes inherited from Options_Field

#option_labels, #options, #options_range, #value

Attributes inherited from Form_Field

#form, #label, #type, #value

Attributes inherited from Element

#attrib, #content, #parent, #tag, #type

Instance Method Summary collapse

Methods inherited from Options_Field

#[], #[]=, #add_option, #content, #initialize

Methods inherited from Form_Field

#disable!, #editable!, #enable!, #initialize, #readonly!, #readonly?, #to_s

Methods inherited from Element

#+, #[], #[]=, #clear_floating, #dom_id, #dom_id=, #each, #empty?, #id, #id=, #initialize, #length, #method_missing, #string, #to_ary

Constructor Details

This class inherits a constructor from Aurita::GUI::Options_Field

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Aurita::GUI::Element

Instance Method Details

#elementObject



26
27
28
29
30
# File 'lib/aurita-gui/form/select_field.rb', line 26

def element
  HTML.select(@attrib) { 
    option_elements()
  } 
end

#option_elementsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aurita-gui/form/select_field.rb', line 8

def option_elements
  options = []
  @option_elements.each { |option| 
    if option.kind_of? Hash then
      option.each_pair { |k,v|
        selected = (@value && k.to_s == @value.to_s)? true : nil
        options << HTML.option(:value => k, :selected => selected) { v }
      }
    elsif option.kind_of? Element then
      option.tag = :option
      options << option
    else 
      selected = (@value && option.to_s == @value.to_s)? true : nil
      options << HTML.option(:value => option, :selected => selected) { option }
    end
  }
  options
end

#readonly_elementObject



31
32
33
34
35
# File 'lib/aurita-gui/form/select_field.rb', line 31

def readonly_element
  HTML.div(@attrib) { 
    @options[@value]
  }
end