2010-07-28 Sergio Martin <sergio.martin@artica.es>

* include/functions_html.php: Improved the print_select function
	to allows agroupation of options



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3076 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2010-07-28 17:44:04 +00:00
parent 2dc897781e
commit 80d6ec2dc6
2 changed files with 23 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2010-07-28 Sergio Martin <sergio.martin@artica.es>
* include/functions_html.php: Improved the print_select function
to allows agroupation of options
2010-07-28 Ramon Novoa <rnovoa@artica.es>
* include/fgraph.php: Async modules are not compressed. Fixed charts

View File

@ -263,7 +263,20 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
if ($sort !== false) {
asort ($fields);
}
$lastopttype = '';
foreach ($fields as $value => $label) {
$optlabel = $label;
if(is_array($label)){
if($label['optgroup'] != $lastopttype) {
if($lastopttype != '') {
$output .= '</optgroup>';
}
$output .= '<optgroup label="'.$label['optgroup'].'">';
$lastopttype = $label['optgroup'];
}
$optlabel = $label['name'];
}
$output .= '<option value="'.$value.'"';
if (is_array ($selected) && in_array ($value, $selected)) {
$output .= ' selected="selected"';
@ -277,12 +290,15 @@ function print_select ($fields, $name, $selected = '', $script = '', $nothing =
if (is_array ($option_style) && in_array ($value, array_keys($option_style))) {
$output .= ' style="'.$option_style[$value].'"';
}
if ($label === '') {
if ($optlabel === '') {
$output .= '>'.$value."</option>";
} else {
$output .= '>'.$label."</option>";
$output .= '>'.$optlabel."</option>";
}
}
if(is_array($label)){
$output .= '</optgroup>';
}
}
$output .= "</select>";