From 890f6ac71bb19a9693b92584f4c3989303769785 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 26 Jun 2008 12:06:06 +0000 Subject: Checkboxes now work happily with arrays. git-svn-id: https://code.elgg.org/elgg/trunk@1144 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/input/checkboxes.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'views/default') 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 "
"; + $labelint = (int) $label; + if ("{$label}" == "{$labelint}") { + $label = $option; + } + echo "
"; } ?> \ No newline at end of file -- cgit v1.2.3