Elgg  Version 6.1
fieldset.php
Go to the documentation of this file.
1 <?php
16 $vars['class'] = elgg_extract_class($vars, ['elgg-fieldset']);
17 
18 $align = elgg_extract('align', $vars, 'vertical');
19 unset($vars['align']);
20 $vars['class'][] = "elgg-fieldset-{$align}";
21 
22 $justify = elgg_extract('justify', $vars);
23 unset($vars['justify']);
24 if (!empty($justify)) {
25  $vars['class'][] = "elgg-justify-{$justify}";
26 }
27 
28 $legend = elgg_extract('legend', $vars, '');
29 unset($vars['legend']);
30 if (!empty($legend)) {
31  $vars['class'][] = 'elgg-fieldset-has-legend';
32  $legend = elgg_format_element('legend', [], $legend);
33 }
34 
35 $fields = (array) elgg_extract('fields', $vars, []);
36 unset($vars['fields']);
37 
38 $fieldset = '';
39 foreach ($fields as $field) {
40  $fieldset .= elgg_view_field($field);
41 }
42 
43 unset($vars['name']); // name isn't allowed on a DIV, but is commonly supplied to input views
44 
45 echo elgg_format_element('fieldset', $vars, $legend . $fieldset);
elgg_view_field(array $params=[])
Renders a form field, usually with a wrapper element, a label, help text, etc.
Definition: views.php:1112
$align
Definition: fieldset.php:18
if(elgg_extract('input_type', $vars)) if(elgg_extract('required', $vars)) if(elgg_extract('disabled', $vars)) $field
Definition: field.php:42
$vars['class']
Renders a set of fields wrapped in a <fieldset> tag.
Definition: fieldset.php:16
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
if(!empty($legend)) $fields
Definition: fieldset.php:35
if(!empty($justify)) $legend
Definition: fieldset.php:28
$fieldset
Definition: fieldset.php:38
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
$justify
Definition: fieldset.php:22