diff options
Diffstat (limited to 'views/default')
-rw-r--r-- | views/default/input/checkbox.php | 18 | ||||
-rw-r--r-- | views/default/input/checkboxes.php | 44 |
2 files changed, 30 insertions, 32 deletions
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 @@ +<?php +/** + * Elgg checkbox input + * Displays a checkbox input field + * + * @package Elgg + * @subpackage Core + */ + +$defaults = array( + 'class' => 'input_checkbox', +); + +$vars = array_merge($defaults, $vars); + +?> + +<input type="checkbox" <?php echo elgg_format_attributes($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 "<label><input $attr_str />$label</label><br />"; + echo "<label>{$input}{$label}</label><br />"; } }
\ No newline at end of file |