Elgg  Version 5.1
form.php
Go to the documentation of this file.
1 <?php
17 elgg_require_js('input/form');
18 
20  'method' => 'post',
21  'disable_security' => false,
22 ];
23 
24 $vars = array_merge($defaults, $vars);
25 
26 $vars['class'] = elgg_extract_class($vars, 'elgg-form');
27 if (elgg_extract('prevent_double_submit', $vars, true)) {
28  $vars['class'][] = 'elgg-form-prevent-double-submit';
29 }
30 
31 $vars['action'] = elgg_normalize_url($vars['action']);
32 $vars['method'] = strtolower($vars['method']);
33 
34 $ignore_empty_body = (bool) elgg_extract('ignore_empty_body', $vars, true);
35 unset($vars['ignore_empty_body']);
36 
38 unset($vars['body']);
39 
40 if (!$ignore_empty_body && empty($body)) {
41  return;
42 }
43 
44 // Generate a security header
45 if (!$vars['disable_security']) {
46  $body = elgg_view('input/securitytoken') . $body;
47 }
48 
49 unset($vars['disable_security']);
50 unset($vars['action_name']);
51 
52 echo elgg_format_element('form', $vars, "<fieldset>$body</fieldset>");
$body
Definition: form.php:37
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
$ignore_empty_body
Definition: form.php:34
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:177
$vars
Definition: form.php:24
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_normalize_url(string $url)
Definition: output.php:163
elgg_require_js(string $name)
Request that Elgg load an AMD module onto the page.
$defaults
Definition: form.php:19