aboutsummaryrefslogtreecommitdiff
path: root/views/default
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 12:06:06 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-26 12:06:06 +0000
commit890f6ac71bb19a9693b92584f4c3989303769785 (patch)
treeb251ea1bfba0ad2080c889ef67159677621481af /views/default
parent85aa957de8319e6c2ca6fc39190bb7fd2c5e602d (diff)
downloadelgg-890f6ac71bb19a9693b92584f4c3989303769785.tar.gz
elgg-890f6ac71bb19a9693b92584f4c3989303769785.tar.bz2
Checkboxes now work happily with arrays.
git-svn-id: https://code.elgg.org/elgg/trunk@1144 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default')
-rw-r--r--views/default/input/checkboxes.php26
1 files changed, 19 insertions, 7 deletions
diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php
index 1a10b8a62..5039b5523 100644
--- a/views/default/input/checkboxes.php
+++ b/views/default/input/checkboxes.php
@@ -18,14 +18,26 @@
*
*/
- foreach($vars['options'] as $option) {
- //if (!in_array($option,$vars['value'])) {
- if ($option != $vars['value']) {
- $selected = "";
- } else {
- $selected = "checked = \"checked\"";
+ foreach($vars['options'] as $label => $option) {
+ //if (!in_array($option,$vars['value'])) {
+ if (is_array($vars['value'])) {
+ if (!in_array($option,$vars['value'])) {
+ $selected = "";
+ } else {
+ $selected = "checked = \"checked\"";
+ }
+ } else {
+ if ($option != $vars['value']) {
+ $selected = "";
+ } else {
+ $selected = "checked = \"checked\"";
+ }
}
- echo "<label><input type=\"checkbox\" {$vars['js']} name=\"{$vars['internalname']}[]\" {$selected} value=\"".htmlentities($option)."\" {$selected} />{$option}</label><br />";
+ $labelint = (int) $label;
+ if ("{$label}" == "{$labelint}") {
+ $label = $option;
+ }
+ echo "<label><input type=\"checkbox\" {$vars['js']} name=\"{$vars['internalname']}[]\" {$selected} value=\"".htmlentities($option)."\" {$selected} />{$label}</label><br />";
}
?> \ No newline at end of file