170 foreach ($this->options as $val =>
$name) {
171 $value[$encode ? htmlspecialchars($val, ENT_QUOTES) : $val] = ($encode > 1)
172 ? htmlspecialchars(
$name, ENT_QUOTES) :
$name;
195 if (!is_array($ele_value)) {
196 $ele_value = (array) $ele_value;
205 if (empty($ele_optgroup)) {
207 $ret .=
'<option value="' . htmlspecialchars(
$value, ENT_QUOTES) .
'"';
208 if (count($ele_value) > 0 && in_array(
$value, $ele_value)) {
209 $ret .=
' selected="selected"';
211 $ret .=
'>' .
$name .
'</option>' . NWLINE;
214 foreach ($ele_optgroup as $name_optgroup => $value_optgroup) {
215 $ret .=
'<optgroup label="' . $name_optgroup .
'">' . NWLINE;
217 $ret .=
'<option value="' . htmlspecialchars(
$value, ENT_QUOTES) .
'"';
218 if (count($ele_value) > 0 && in_array(
$value, $ele_value)) {
219 $ret .=
' selected="selected"';
221 $ret .=
'>' .
$name .
'</option>' . NWLINE;
223 $ret .=
'</optgroup>' . NWLINE;
226 $ret .=
'</select>' . NWLINE;
238 if (!empty($this->customValidationCode)) {
239 return implode(
"\n", $this->customValidationCode);
244 $eltmsg = empty($eltcaption)
247 $eltmsg = str_replace(
'"',
'\"', stripslashes($eltmsg));
248 return "\nvar hasSelected = false; var selectBox = myform.{$eltname};"
249 .
"for (i = 0; i < selectBox.options.length; i++ ) { "
250 .
"if (selectBox.options[i].selected == true && selectBox.options[i].value != '') "
251 .
"{ hasSelected = true; break; } }" .
"if (!hasSelected) "
252 .
"{ window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }";
setAttribute($name, $value=null)