aboutsummaryrefslogtreecommitdiff
path: root/views/default/input
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 18:33:26 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 18:33:26 +0000
commit2e42219f0ee4bc07f8f3c262242e06ad4f92023e (patch)
tree4a8116ee9741c3cd357b906e30dd5da2470b5933 /views/default/input
parent87c87227c4171e1c706939f746362bcaa56212df (diff)
downloadelgg-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
Diffstat (limited to 'views/default/input')
-rw-r--r--views/default/input/pulldown.php32
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