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, #option_values, #value

Attributes inherited from Form_Field

#data_type, #form, #hidden, #hint, #invalid, #label, #required, #type, #value

Attributes inherited from Element

#attrib, #force_closing_tag, #gui_element_id, #parent, #tag

Instance Method Summary collapse

Methods inherited from Options_Field

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

Methods inherited from Form_Field

#disable!, #disabled=, #editable!, #enable!, #hidden?, #hide!, #initialize, #invalid!, #invalid?, #optional!, #readonly!, #readonly=, #readonly?, #required!, #required?, #show!, #to_hidden_field, #to_s

Methods inherited from Element

#+, #<<, #[], #[]=, #add_class, #aurita_gui_element, #clear_floating, #css_classes, #find_by_dom_id, #get_content, #has_content?, #id, #id=, #initialize, #inspect, #js_init_code, #length, #method_missing, #recurse, #remove_class, #set_content, #string, #swap, #to_ary, #touch, #touched?, #type=, #untouch

Methods included from Marshal_Helper_Class_Methods

#marshal_load

Methods included from Marshal_Helper

#marshal_dump

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



20
21
22
23
24
# File 'lib/aurita-gui/form/select_field.rb', line 20

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

#option_elementsObject

Returns array of option elements for this select field.



11
12
13
14
15
16
17
18
# File 'lib/aurita-gui/form/select_field.rb', line 11

def option_elements
  elements = []
  options().each_pair { |k,v|
    selected = (@value && k.to_s == @value.to_s)? true : nil
    elements << HTML.option(:value => k, :selected => selected) { v }
  }
  elements
end

#readonly_elementObject



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

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