allow descriptive select fields

This commit is contained in:
Roland Gruber 2006-03-14 17:58:52 +00:00
parent c1cdb15d70
commit c8c7125e04
2 changed files with 18 additions and 3 deletions

View File

@ -932,6 +932,12 @@ string. This is the list of option values the user can select.</li>
<li><span style="font-weight: bold;">options_selected:</span> Array
of string. This is the list of pre selected elements, must contain
values that are also in <span style="font-style: italic;">options</span>.</li>
<li><span style="font-weight: bold;">descriptiveOptions:</span>
Boolean value, if set to true then all elements in the options and
options_selected arrays must be arrays themselves (array(<span
style="font-style: italic;">value</span>, <span
style="font-style: italic;">description</span>)) (default: false)<br>
</li>
<li><span style="font-weight: bold;">size:</span> The size of the
select field, if set to 1 a dropdown box will be displayed.</li>
<li><span style="font-weight: bold;">noSorting:</span> If set to

View File

@ -641,13 +641,21 @@ function parseHtml($module, $input, $values, $restricted, &$tabindex, &$tabindex
}
if (isset($values[$input[$i][$j]['name']])) $input[$i][$j]['options_selected'] = $values[$input[$i][$j]['name']];
// merge both option arrays and sort them.
$options = array_merge ($input[$i][$j]['options'], $input[$i][$j]['options_selected'] );
$options = array_unique($options);
$options = $input[$i][$j]['options'];
if (!isset($input[$i][$j]['descriptiveOptions']) || ($input[$i][$j]['descriptiveOptions'] === false)) {
// merge both option arrays and sort them.
$options = array_merge($input[$i][$j]['options'], $input[$i][$j]['options_selected'] );
$options = array_unique($options);
}
if (!isset($input[$i][$j]['noSorting']) || !$input[$i][$j]['noSorting']) {
sort($options);
}
foreach ($options as $option) {
if ($option!='') {
if (isset($input[$i][$j]['descriptiveOptions']) && ($input[$i][$j]['descriptiveOptions'] === true)) {
if (in_array($option[0], $input[$i][$j]['options_selected'])) echo "<option value=\"" . $option[0] . "\" selected>" . $option[1] . "</option>\n";
else echo "<option value=\"" . $option[0] . "\">" . $option[1] . "</option>\n";
}
elseif ($option!='') {
if (in_array($option, $input[$i][$j]['options_selected'])) echo "<option selected>" . $option . "</option>\n";
else echo "<option>" . $option . "</option>\n";
}
@ -695,6 +703,7 @@ function parseHtml($module, $input, $values, $restricted, &$tabindex, &$tabindex
return $ret;
}
/**
* This class includes all modules and attributes of an account.
*