aboutsummaryrefslogtreecommitdiff
path: root/views/default
diff options
context:
space:
mode:
Diffstat (limited to 'views/default')
-rw-r--r--views/default/input/pulldown.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/views/default/input/pulldown.php b/views/default/input/pulldown.php
index 54764bbd0..a9663ef82 100644
--- a/views/default/input/pulldown.php
+++ b/views/default/input/pulldown.php
@@ -3,6 +3,8 @@
* Elgg pulldown input
* Displays a pulldown input field
*
+ * NB: Default values of FALSE or NULL will match '' (empty string) and not 0.
+ *
* @package Elgg
* @subpackage Core
* @author Curverider Ltd
@@ -21,7 +23,7 @@ if (!$class) {
$class = "input_pulldown";
}
-if (!isset($vars['value']) || $vars['value'] === FALSE) {
+if (!isset($vars['value'])) {
$vars['value'] = elgg_get_sticky_value($vars['internalname']);
}
@@ -31,24 +33,24 @@ if (!isset($vars['value']) || $vars['value'] === FALSE) {
if ($vars['options_values']) {
foreach($vars['options_values'] as $value => $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>";
+ $encoded_value = htmlentities($value, ENT_QUOTES, 'UTF-8');
+ $encoded_option = htmlentities($option, ENT_QUOTES, 'UTF-8');
+
+ if ((string)$value == (string)$vars['value']) {
+ echo "<option value=\"$encoded_value\" selected=\"selected\">$encoded_option</option>";
} else {
- echo "<option value=\"$value\">$option</option>";
+ echo "<option value=\"$encoded_value\">$encoded_option</option>";
}
}
} else {
foreach($vars['options'] as $option) {
- $option = htmlentities($option, ENT_QUOTES, 'UTF-8');
+ $encoded_option = htmlentities($option, ENT_QUOTES, 'UTF-8');
- if (strcmp($value, $vars['value']) == 0) {
- echo "<option selected=\"selected\">$option</option>";
+ if ((string)$value == (string)$vars['value']) {
+ echo "<option selected=\"selected\">$encoded_option</option>";
} else {
- echo "<option>$option</option>";
+ echo "<option>$encoded_option</option>";
}
}
}