From e61a98c5dd04391db3eb7e3a087de633e2a6b0fe Mon Sep 17 00:00:00 2001 From: ewinslow Date: Sat, 20 Nov 2010 09:28:42 +0000 Subject: Fixes #2396: Added a new input/checkbox view. input/checkboxes harnesses it git-svn-id: http://code.elgg.org/elgg/trunk@7372 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/input/checkbox.php | 18 ++++++++++++++++ views/default/input/checkboxes.php | 44 +++++++++++--------------------------- 2 files changed, 30 insertions(+), 32 deletions(-) create mode 100644 views/default/input/checkbox.php (limited to 'views/default') diff --git a/views/default/input/checkbox.php b/views/default/input/checkbox.php new file mode 100644 index 000000000..32bc323fd --- /dev/null +++ b/views/default/input/checkbox.php @@ -0,0 +1,18 @@ + 'input_checkbox', +); + +$vars = array_merge($defaults, $vars); + +?> + + /> \ No newline at end of file diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php index adfe19914..46254633b 100644 --- a/views/default/input/checkboxes.php +++ b/views/default/input/checkboxes.php @@ -52,44 +52,24 @@ if ($options) { $label = $option; } - if (!in_array(strtolower($option), $value_array)) { - $selected = FALSE; - } else { - $selected = TRUE; - } - - $attr = array( - 'type="checkbox"', - 'value="' . htmlentities($option, ENT_QUOTES, 'UTF-8') . '"' + $input_vars = array( + 'checked' => in_array(strtolower($option), $value_array), + 'value' => $option, + 'disabled' => $disabled, + 'id' => $id, + 'js' => $js, ); - - if ($id) { - $attr[] = "id=\"$id\""; - } - + if ($class) { - $attr[] = "class=\"$class\""; - } - - if ($disabled) { - $attr[] = 'disabled="yes"'; - } - - if ($selected) { - $attr[] = 'checked = "checked"'; - } - - if ($js) { - $attr[] = $js; + $input_vars['class'] = $class; } if ($internalname) { - // @todo this really, really should only add the []s if there are > 1 element in options. - $attr[] = "name=\"{$internalname}[]\""; + $input_vars['name'] = "{$internalname}[]"; } + + $input = elgg_view('input/checkbox', $input_vars); - $attr_str = implode(' ', $attr); - - echo "
"; + echo "
"; } } \ No newline at end of file -- cgit v1.2.3