From c8c7125e04022e2eff408fac9c65646213dbe04f Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 14 Mar 2006 17:58:52 +0000 Subject: [PATCH] allow descriptive select fields --- lam/docs/devel/modules-specification.htm | 6 ++++++ lam/lib/modules.inc | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lam/docs/devel/modules-specification.htm b/lam/docs/devel/modules-specification.htm index 265f8032..f380ece5 100644 --- a/lam/docs/devel/modules-specification.htm +++ b/lam/docs/devel/modules-specification.htm @@ -932,6 +932,12 @@ string. This is the list of option values the user can select.
  • options_selected: Array of string. This is the list of pre selected elements, must contain values that are also in options.
  • +
  • descriptiveOptions: +Boolean value, if set to true then all elements in the options and +options_selected arrays must be arrays themselves (array(value, description)) (default: false)
    +
  • size: The size of the select field, if set to 1 a dropdown box will be displayed.
  • noSorting: If set to diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 364449a0..05117a0c 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -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 "\n"; + else echo "\n"; + } + elseif ($option!='') { if (in_array($option, $input[$i][$j]['options_selected'])) echo "\n"; else echo "\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. *