Elgg  Version 4.3
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 $vars['action'] = elgg_normalize_url($vars['action']);
31 $vars['method'] = strtolower($vars['method']);
32 
33 $ignore_empty_body = (bool) elgg_extract('ignore_empty_body', $vars, true);
34 unset($vars['ignore_empty_body']);
35 
37 unset($vars['body']);
38 
39 if (!$ignore_empty_body && empty($body)) {
40  return;
41 }
42 
43 // Generate a security header
44 if (!$vars['disable_security']) {
45  $body = elgg_view('input/securitytoken') . $body;
46 }
47 unset($vars['disable_security']);
48 unset($vars['action_name']);
49 
50 echo elgg_format_element('form', $vars, "<fieldset>$body</fieldset>");
elgg_normalize_url($url)
Definition: output.php:153
$body
Definition: form.php:36
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:569
$ignore_empty_body
Definition: form.php:33
$vars
Definition: form.php:24
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:547
elgg echo
Translates a string.
Definition: deprecated.js:530
$defaults
Definition: form.php:19
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:179