Class: SodaCheckBoxField

Inherits:
SodaField show all
Defined in:
lib/fields/CheckBoxField.rb

Overview

SodaCheckBoxField – Class

This is a simple class for dealing with Checkbox fields.

Direct Known Subclasses

SodaRadioField

Class Method Summary collapse

Methods inherited from SodaField

alertHack, append, clear, click, disabled, enabled, focus, getStringTrue, getText, getValue, jsevent, uploadFile

Class Method Details

.assert(field, value) ⇒ Object

assert – Method



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fields/CheckBoxField.rb', line 67

def self.assert(field, value)
   result = nil

   if (value.kind_of? Regexp)
      $curSoda.rep.log("Warning: Regex does not work on checkbox fields\n")
   end
   
   value = self.getStringTrue(value)
   $curSoda.rep.log("Field Value: #{field.checked?()}\n")

   if (value)
      result = field.checked?()
   else
      result = !field.checked?() 
   end

   return result
end

.set(field, value) ⇒ Object

set – Method

This sets the value for a given field.

Params:

field: The field to set a value on.
value: The value to set.

Results:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fields/CheckBoxField.rb', line 46

def self.set(field, value)
   result = 0

   if (!field.enabled?)
      $curSoda.rep.ReportFailure(
         "Error: Trying to set a value for a disabled Element!\n")
   else
      value = self.getStringTrue(value)
      field.set(value)
      result = 0
   end

   return result
end