From 5041c6c48153453ed597206d08eeff37cf20e676 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 15 Mar 2014 14:46:48 -0300 Subject: Squashed 'mod/cool_theme/' content from commit a26f7df git-subtree-dir: mod/cool_theme git-subtree-split: a26f7df43a266f7d1ff04847da330d15f6041e9b --- views/default/input/checkboxes.php | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 views/default/input/checkboxes.php (limited to 'views/default/input/checkboxes.php') diff --git a/views/default/input/checkboxes.php b/views/default/input/checkboxes.php new file mode 100644 index 000000000..db4b06949 --- /dev/null +++ b/views/default/input/checkboxes.php @@ -0,0 +1,90 @@ + option for the each checkbox field + * @uses string $vars['default'] The default value to send if nothing is checked. + * Optional, defaults to 0. Set to FALSE for no default. + * @uses bool $vars['disabled'] Make all input elements disabled. Optional. + * @uses string $vars['value'] The current value. Single value or array. Optional. + * @uses string $vars['class'] Additional class of the list. Optional. + * @uses string $vars['align'] 'horizontal' or 'vertical' Default: 'vertical' + * + */ + +$defaults = array( + 'align' => 'vertical', + 'value' => array(), + 'default' => 0, + 'disabled' => false, + 'options' => array(), + 'name' => '', +); + +$vars = array_merge($defaults, $vars); + +$class = "elgg-input-checkboxes elgg-{$vars['align']}"; +if (isset($vars['class'])) { + $class .= " {$vars['class']}"; + unset($vars['class']); +} + +$id = ''; +if (isset($vars['id'])) { + $id = "id=\"{$vars['id']}\""; + unset($vars['id']); +} + +if (is_array($vars['value'])) { + $values = array_map('elgg_strtolower', $vars['value']); +} else { + $values = array(elgg_strtolower($vars['value'])); +} + +$input_vars = $vars; +$input_vars['default'] = false; +if ($vars['name']) { + $input_vars['name'] = "{$vars['name']}[]"; +} +unset($input_vars['align']); +unset($input_vars['options']); + +if (count($vars['options']) > 0) { + // include a default value so if nothing is checked 0 will be passed. + if ($vars['name'] && $vars['default'] !== false) { + echo ""; + } + + echo "'; +} -- cgit v1.2.3