Elgg  Version 2.3
checkbox.php
Go to the documentation of this file.
1 <?php
24 $vars['class'] = elgg_extract_class($vars, 'elgg-input-checkbox');
25 
26 $defaults = array(
27  'default' => 0,
28  'disabled' => false,
29  'type' => 'checkbox'
30 );
31 
32 $vars = array_merge($defaults, $vars);
33 
34 $default = $vars['default'];
35 unset($vars['default']);
36 
37 if (isset($vars['name']) && $default !== false) {
38  echo elgg_view('input/hidden', ['name' => $vars['name'], 'value' => $default]);
39 }
40 
41 $label = elgg_extract('label', $vars, false);
42 $label_class = (array) elgg_extract('label_class', $vars, []);
43 $label_class[] = 'elgg-input-single-checkbox';
44 unset($vars['label']);
45 unset($vars['label_class']);
46 
48 
49 if (!empty($label)) {
50  $html_tag = elgg_extract('label_tag', $vars, 'label', false);
51  echo elgg_format_element($html_tag, ['class' => $label_class], "$input $label");
52 } else {
53  echo $input;
54 }
$label_class
Definition: checkbox.php:42
$default
Definition: checkbox.php:34
$input
Definition: checkbox.php:47
elgg_extract_class(array $array, $existing=[])
Extract class names from an array with key "class", optionally merging into a preexisting set...
Definition: elgglib.php:1396
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
elgg echo
Translates a string.
Definition: languages.js:48
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
$vars['class']
Definition: checkbox.php:24
$defaults
Definition: checkbox.php:26
if(isset($vars['name'])&&$default!==false) $label
Definition: checkbox.php:41