Elgg  Version 6.0
label.php
Go to the documentation of this file.
1 <?php
10 $label = elgg_extract('label', $vars, '');
12 $required = elgg_extract('required', $vars);
13 
14 if (!$label) {
15  return;
16 }
17 
18 if ($required) {
19  $indicator = elgg_extract('required_indicator', $vars);
20  if (!isset($indicator)) {
21  $indicator = elgg_format_element('span', [
22  'title' => elgg_echo('field:required'),
23  'class' => 'elgg-required-indicator',
24  ], '&ast;');
25  }
26 
27  if ($indicator) {
28  $label .= $indicator;
29  }
30 }
31 
32 echo elgg_format_element('label', [
33  'for' => $id,
34  'class' => 'elgg-field-label'
35 ], $label);
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
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
$label
Form input label view.
Definition: label.php:10
$vars
Definition: theme.php:5
$required
Definition: label.php:12
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
$id
Definition: label.php:11