aboutsummaryrefslogtreecommitdiff
path: root/views/default/input/checkbox.php
blob: 59af3216fa75eae4acd645dc31be6db0096ab775 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
 * Elgg checkbox input
 * Displays a checkbox input tag
 * 
 * @package Elgg
 * @subpackage Core
 *
 *
 * Pass input tag attributes as key value pairs. For a list of allowable
 * attributes, see http://www.w3schools.com/tags/tag_input.asp
 * 
 * @uses mixed $vars['default'] The default value to submit if not checked.
 *                              Optional, defaults to 0. Set to false for no default.
 */

$defaults = array(
	'class' => 'input-checkbox',
);

$vars = array_merge($defaults, $vars);

if (isset($vars['default'])) {
	$default = $vars['default'];
	unset($vars['default']);
} else {
	$default = 0;
}

if (isset($vars['name']) && $default !== false) {
	echo "<input type=\"hidden\" name=\"{$vars['name']}\" value=\"$default\"/>";
}

?>

<input type="checkbox" <?php echo elgg_format_attributes($vars); ?> />