Elgg  Version 1.11
checkbox.php
Go to the documentation of this file.
1 <?php
23 $vars['class'] = (array) elgg_extract('class', $vars, []);
24 $vars['class'][] = '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 = elgg_extract('label_class', $vars);
43 unset($vars['label']);
44 unset($vars['label_class']);
45 
47 
48 if (!empty($label)) {
49  echo elgg_format_element('label', ['class' => $label_class], "$input $label");
50 } else {
51  echo $input;
52 }
$label_class
Definition: checkbox.php:42
$default
Definition: checkbox.php:34
$input
Definition: checkbox.php:46
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1246
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:215
elgg echo
Translates a string.
Definition: languages.js:43
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$vars['class']
Definition: checkbox.php:23
$defaults
Definition: checkbox.php:26
if(isset($vars['name'])&&$default!==false) $label
Definition: checkbox.php:41