Elgg  Version master
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('required', $vars)) {
31  $class[] = 'elgg-field-required';
32 }
33 
34 if (elgg_extract('disabled', $vars)) {
35  $class[] = 'elgg-field-disabled';
36 }
37 
39 
40 echo elgg_format_element('div', [
41  'class' => $class,
42 ], $field);
if($view &&elgg_view_exists($view)) $label
Definition: field.php:26
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:276
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:254
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
$class
Definition: field.php:29
$help
Definition: field.php:27
if(elgg_extract('required', $vars)) if(elgg_extract('disabled', $vars)) $field
Definition: field.php:38
$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
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:152