Elgg  Version 6.1
field.php
Go to the documentation of this file.
1 <?php
14 if (empty($input)) {
15  return;
16 }
17 
19 unset($vars['view']);
20 
21 if ($view && elgg_view_exists($view)) {
22  echo elgg_view($view, $vars);
23  return;
24 }
25 
26 $label = elgg_extract('label', $vars, '');
27 $help = elgg_extract('help', $vars, '');
28 
29 $class = elgg_extract_class($vars, 'elgg-field');
30 if (elgg_extract('input_type', $vars)) {
31  $class[] = 'elgg-field-' . elgg_extract('input_type', $vars);
32 }
33 
34 if (elgg_extract('required', $vars)) {
35  $class[] = 'elgg-field-required';
36 }
37 
38 if (elgg_extract('disabled', $vars)) {
39  $class[] = 'elgg-field-disabled';
40 }
41 
43 
44 echo elgg_format_element('div', ['class' => $class], $field);
if($view &&elgg_view_exists($view)) $label
Definition: field.php:26
if(elgg_extract('input_type', $vars)) if(elgg_extract('required', $vars)) if(elgg_extract('disabled', $vars)) $field
Definition: field.php:42
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:256
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
$class
Definition: field.php:29
$help
Definition: field.php:27
$vars
Definition: theme.php:5
$input
Form field view.
Definition: field.php:13
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_extract_class(array $array, array|string $existing=[], string $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:279
if(empty($input)) $view
Definition: field.php:18
elgg_view_exists(string $view, string $viewtype= '', bool $recurse=true)
Returns whether the specified view exists.
Definition: views.php:131