Class: Aurita::GUI::Boolean_Field

Inherits:
Checkbox_Field show all
Defined in:
lib/aurita-gui/form/boolean_field.rb

Overview

Convenience configuration of Checkbox_Field. Renders one checkbox with :options => [1]

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 Checkbox_Field

#element

Methods inherited from Options_Field

#[], #[]=, #add_option, #content, #element, #option_hash, #options, #options=, #readonly_element

Methods inherited from Form_Field

#disable!, #disabled=, #editable!, #element, #enable!, #hidden?, #hide!, #invalid!, #invalid?, #optional!, #readonly!, #readonly=, #readonly?, #readonly_element, #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=, #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

#initialize(params, &block) ⇒ Boolean_Field

Returns a new instance of Boolean_Field.



10
11
12
13
# File 'lib/aurita-gui/form/boolean_field.rb', line 10

def initialize(params, &block)
  params[:options] = [ 1 ]
  super(params, &block)
end

Dynamic Method Handling

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

Instance Method Details

#option_elementsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/aurita-gui/form/boolean_field.rb', line 14

def option_elements
  elements = []
  options().each_pair { |k,v|
    box_attribs = { :type => :checkbox, 
                    :value => k, 
                    :name => @attrib[:name] }
    checked = (@value && k.to_s == @value.to_s)? true : nil
    box_attribs[:checked] = checked
    element = []
    element << HTML.input(box_attribs) 
    elements << element
  }
  elements
end