44 |
*/ |
*/ |
45 |
function FEDataList($label, $required = TRUE, $width = NULL, $height = NULL, $data_list = array()) { |
function FEDataList($label, $required = TRUE, $width = NULL, $height = NULL, $data_list = array()) { |
46 |
$this->FEBoxElement($label, $required, $width, $height); |
$this->FEBoxElement($label, $required, $width, $height); |
47 |
|
$this->set_list_data( $data_list ); |
48 |
|
} |
49 |
|
|
50 |
|
/** |
51 |
|
* This function sets the array of data |
52 |
|
* to be used in the data list |
53 |
|
* |
54 |
|
* @param array data_list - list of data elements (name=>value) |
55 |
|
*/ |
56 |
|
function set_list_data( $data_list = array() ) { |
57 |
$this->_data_list = $data_list; |
$this->_data_list = $data_list; |
58 |
} |
} |
59 |
|
|
73 |
*/ |
*/ |
74 |
function get_value_text($value) { |
function get_value_text($value) { |
75 |
$flip = array_flip($this->_data_list); |
$flip = array_flip($this->_data_list); |
76 |
return $flip[$value]; |
if (array_key_exists($value, $flip)) { |
77 |
|
return $flip[$value]; |
78 |
|
} else { |
79 |
|
return NULL; |
80 |
|
} |
81 |
} |
} |
82 |
|
|
83 |
/** |
/** |
86 |
* validation and setting the appropriate error message |
* validation and setting the appropriate error message |
87 |
* in case of a failed validation |
* in case of a failed validation |
88 |
* |
* |
89 |
|
* @param FormValidation object |
90 |
*/ |
*/ |
91 |
function validate() { |
function validate(&$_FormValidation) { |
92 |
// we make sure that the value is in the data list |
// we make sure that the value is in the data list |
93 |
$values = $this->get_value(); |
$values = $this->get_value(); |
94 |
if (is_array($values) ) { |
if (is_array($values) ) { |