Elgg  Version 6.1
form.php
Go to the documentation of this file.
1 <?php
18  'method' => 'post',
19  'disable_security' => false,
20 ];
21 
22 $vars = array_merge($defaults, $vars);
23 
24 $ignore_empty_body = (bool) elgg_extract('ignore_empty_body', $vars, true);
25 unset($vars['ignore_empty_body']);
26 
28 unset($vars['body']);
29 
30 if (!$ignore_empty_body && empty($body)) {
31  return;
32 }
33 
34 $vars['class'] = elgg_extract_class($vars, 'elgg-form');
35 if (elgg_extract('prevent_double_submit', $vars, true)) {
36  elgg_import_esm('input/form-double-submit');
37  $vars['class'][] = 'elgg-form-prevent-double-submit';
38 }
39 
40 $vars['action'] = elgg_normalize_url((string) $vars['action']);
41 $vars['method'] = strtolower((string) $vars['method']);
42 
43 // Generate a security header
44 if (!$vars['disable_security']) {
45  $body = elgg_view('input/securitytoken') . $body;
46 }
47 
48 unset($vars['disable_security']);
49 unset($vars['action_name']);
50 
51 echo elgg_format_element('form', $vars, $body);
$body
Definition: form.php:27
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
$ignore_empty_body
Definition: form.php:24
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
$vars
Definition: form.php:22
elgg_import_esm(string $name)
Helper functions for external files like css/js.
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
elgg_normalize_url(string $url)
Definition: output.php:163
$defaults
Create a form for data submission.
Definition: form.php:17