diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-26 18:33:26 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-26 18:33:26 +0000 |
commit | 2e42219f0ee4bc07f8f3c262242e06ad4f92023e (patch) | |
tree | 4a8116ee9741c3cd357b906e30dd5da2470b5933 | |
parent | 87c87227c4171e1c706939f746362bcaa56212df (diff) | |
download | elgg-2e42219f0ee4bc07f8f3c262242e06ad4f92023e.tar.gz elgg-2e42219f0ee4bc07f8f3c262242e06ad4f92023e.tar.bz2 |
Pulldown menu view now supports passing values as well as options as an associative array "value" => "option text" called $vars['options_values']
git-svn-id: https://code.elgg.org/elgg/trunk@1156 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | views/default/input/pulldown.php | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/views/default/input/pulldown.php b/views/default/input/pulldown.php index a83534c41..520a62c88 100644 --- a/views/default/input/pulldown.php +++ b/views/default/input/pulldown.php @@ -15,7 +15,8 @@ * @uses $vars['js'] Any Javascript to enter into the input tag
* @uses $vars['internalname'] The name of the input field
* @uses $vars['options'] An array of strings representing the options for the pulldown field
- *
+ * @uses $vars['options_values'] An associative array of "value" => "option" where "value" is an internal name and "option" is + * the value displayed on the button. Replaces $vars['options'] when defined.
*/
?>
@@ -23,14 +24,25 @@ <select name="<?php echo $vars['internalname']; ?>" <?php echo $vars['js']; ?>>
<?php
-
- foreach($vars['options'] as $option) {
- if ($option != $vars['value']) {
- echo "<option>{$option}</option>";
- } else {
- echo "<option selected=\"selected\">{$option}</option>";
- }
- }
-
+ if ($vars['options_values']) + { + foreach($vars['options_values'] as $value => $option) { + if ($value != $vars['value']) { + echo "<option value=\"$value\">{$option}</option>"; + } else { + echo "<option value=\"$value\" selected=\"selected\">{$option}</option>"; + } + } + } + else + {
+ foreach($vars['options'] as $option) {
+ if ($option != $vars['value']) {
+ echo "<option>{$option}</option>";
+ } else {
+ echo "<option selected=\"selected\">{$option}</option>";
+ }
+ }
+ }
?>
</select>
\ No newline at end of file |