Elgg  Version 3.0
form.php
Go to the documentation of this file.
1 <?php
19 elgg_require_js('input/form');
20 
22  'method' => 'post',
23  'disable_security' => false,
24 ];
25 
26 $vars = array_merge($defaults, $vars);
27 
28 $vars['class'] = elgg_extract_class($vars, 'elgg-form');
29 $vars['action'] = elgg_normalize_url($vars['action']);
30 $vars['method'] = strtolower($vars['method']);
31 
32 $ignore_empty_body = (bool) elgg_extract('ignore_empty_body', $vars, true);
33 unset($vars['ignore_empty_body']);
34 
36 unset($vars['body']);
37 
38 if (!$ignore_empty_body && empty($body)) {
39  return;
40 }
41 
42 // Generate a security header
43 if (!$vars['disable_security']) {
44  $body = elgg_view('input/securitytoken') . $body;
45 }
46 unset($vars['disable_security']);
47 unset($vars['action_name']);
48 
49 echo elgg_format_element('form', $vars, "<fieldset>$body</fieldset>");
elgg_normalize_url($url)
Definition: output.php:186
$body
Definition: form.php:35
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
$ignore_empty_body
Definition: form.php:32
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
Definition: elgglib.php:168
$vars
Definition: form.php:26
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg echo
Translates a string.
Definition: languages.js:43
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:1131
$defaults
Definition: form.php:21
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246