4 |
* |
* |
5 |
* $Id$ |
* $Id$ |
6 |
* |
* |
7 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
8 |
* @author Suren Markosyan <suren@bcsweb.com> |
* @author Suren Markosyan <suren@bcsweb.com> |
9 |
* @package phpHtmlLib |
* @package phpHtmlLib |
10 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
18 |
* a complex FEBoxElement. It has no validation method. |
* a complex FEBoxElement. It has no validation method. |
19 |
* |
* |
20 |
* |
* |
21 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
* @author Walter A. Boring IV <waboring@newsblob.com> |
22 |
* @author Suren Markossian <suren@bcsweb.com> |
* @author Suren Markossian <suren@bcsweb.com> |
23 |
* @package phpHtmlLib |
* @package phpHtmlLib |
24 |
* @subpackage FormProcessing |
* @subpackage FormProcessing |
35 |
var $_data_list = array(); |
var $_data_list = array(); |
36 |
|
|
37 |
/** |
/** |
38 |
|
* The list of disabled items |
39 |
|
* (if any) |
40 |
|
*/ |
41 |
|
var $_disabled_items = array(); |
42 |
|
|
43 |
|
/** |
44 |
* The constructor |
* The constructor |
45 |
* |
* |
46 |
* @param label string - text label for the element |
* @param string text label for the element |
47 |
* @param bool required - is this a required element |
* @param boolean is this a required element? |
48 |
|
* @param int element width in characters, pixels (px), percentage (%) or elements (em) |
49 |
|
* @param int element height in px |
50 |
* @param array data_list - list of data elements (name=>value) |
* @param array data_list - list of data elements (name=>value) |
|
* @param int required - element width in characters, pixels (px), percentage (%) or elements (em) |
|
51 |
*/ |
*/ |
52 |
function FEDataList($label, $required = TRUE, $width = NULL, $height = NULL, $data_list = array()) { |
function FEDataList($label, $required = TRUE, $width = NULL, $height = NULL, $data_list = array()) { |
53 |
$this->FEBoxElement($label, $required, $width, $height); |
$this->set_list_data( $data_list ); |
54 |
|
$this->FEBoxElement($label, $required, $width, $height); |
55 |
|
} |
56 |
|
|
57 |
|
/** |
58 |
|
* This function sets the array of data |
59 |
|
* to be used in the data list |
60 |
|
* |
61 |
|
* @param array data_list - list of data elements (name=>value) |
62 |
|
*/ |
63 |
|
function set_list_data( $data_list = array() ) { |
64 |
$this->_data_list = $data_list; |
$this->_data_list = $data_list; |
65 |
} |
} |
66 |
|
|
75 |
* associated with a field. |
* associated with a field. |
76 |
* It is used during Confirmation |
* It is used during Confirmation |
77 |
* |
* |
|
* @param mixed - the value to look up |
|
78 |
* @return string - the text associated |
* @return string - the text associated |
79 |
*/ |
*/ |
80 |
function get_value_text($value) { |
function get_value_text() { |
81 |
|
$value = $this->get_value(); |
82 |
$flip = array_flip($this->_data_list); |
$flip = array_flip($this->_data_list); |
83 |
return $flip[$value]; |
if (array_key_exists($value, $flip)) { |
84 |
|
return $flip[$value]; |
85 |
|
} else { |
86 |
|
return NULL; |
87 |
|
} |
88 |
} |
} |
89 |
|
|
90 |
/** |
/** |
93 |
* validation and setting the appropriate error message |
* validation and setting the appropriate error message |
94 |
* in case of a failed validation |
* in case of a failed validation |
95 |
* |
* |
96 |
|
* @param FormValidation object |
97 |
*/ |
*/ |
98 |
function validate() { |
function validate(&$_FormValidation) { |
99 |
// we make sure that the value is in the data list |
// we make sure that the value is in the data list |
100 |
$values = $this->get_value(); |
$values = $this->get_value(); |
101 |
if (is_array($values) ) { |
if (is_array($values) ) { |
111 |
return FALSE; |
return FALSE; |
112 |
} |
} |
113 |
} |
} |
|
|
|
|
|
|
114 |
return TRUE; |
return TRUE; |
115 |
} |
} |
116 |
|
|
117 |
|
/** |
118 |
|
* This method allows you to disable one of the items |
119 |
|
* in the list of checkboxes. |
120 |
|
* |
121 |
|
* @param string the name of the checkbox to disable |
122 |
|
* @return none |
123 |
|
*/ |
124 |
|
function disable_item($name) { |
125 |
|
$this->_disabled_items[$name] = 1; |
126 |
|
} |
127 |
} |
} |
128 |
?> |
?> |