aboutsummaryrefslogtreecommitdiff
path: root/views/default/input
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-17 01:39:07 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-17 01:39:07 +0000
commit320d0035b6ba5f5078a9ef03ee880403c858e64e (patch)
tree19c7588edd05a8e6b381f21a2264fe0f43c57bbe /views/default/input
parentf7066400258f9314293175b0d2b9c5ee1fb3441c (diff)
downloadelgg-320d0035b6ba5f5078a9ef03ee880403c858e64e.tar.gz
elgg-320d0035b6ba5f5078a9ef03ee880403c858e64e.tar.bz2
Refs #1362: Fixed a problem when comparing int and string values to determin the pulldown's selected value.
git-svn-id: http://code.elgg.org/elgg/trunk@5424 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/input')
-rw-r--r--views/default/input/pulldown.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/views/default/input/pulldown.php b/views/default/input/pulldown.php
index b24d92b38..54764bbd0 100644
--- a/views/default/input/pulldown.php
+++ b/views/default/input/pulldown.php
@@ -26,23 +26,29 @@ if (!isset($vars['value']) || $vars['value'] === FALSE) {
}
?>
-
<select name="<?php echo $vars['internalname']; ?>" <?php if (isset($vars['internalid'])) echo "id=\"{$vars['internalid']}\""; ?> <?php echo $vars['js']; ?> <?php if ($vars['disabled']) echo ' disabled="yes" '; ?> class="<?php echo $class; ?>">
<?php
+
if ($vars['options_values']) {
foreach($vars['options_values'] as $value => $option) {
- if ($value != $vars['value']) {
- echo "<option value=\"".htmlentities($value, ENT_QUOTES, 'UTF-8')."\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+ $value = htmlentities($value, ENT_QUOTES, 'UTF-8');
+ $option = htmlentities($option, ENT_QUOTES, 'UTF-8');
+
+ // use strcmp() because (0 == 'string') is true
+ if (strcmp($value, $vars['value']) == 0) {
+ echo "<option value=\"$value\" selected=\"selected\">$option</option>";
} else {
- echo "<option value=\"".htmlentities($value, ENT_QUOTES, 'UTF-8')."\" selected=\"selected\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+ echo "<option value=\"$value\">$option</option>";
}
}
} else {
foreach($vars['options'] as $option) {
- if ($option != $vars['value']) {
- echo "<option>". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+ $option = htmlentities($option, ENT_QUOTES, 'UTF-8');
+
+ if (strcmp($value, $vars['value']) == 0) {
+ echo "<option selected=\"selected\">$option</option>";
} else {
- echo "<option selected=\"selected\">". htmlentities($option, ENT_QUOTES, 'UTF-8') ."</option>";
+ echo "<option>$option</option>";
}
}
}