diff options
Diffstat (limited to 'views/default/input/form.php')
-rw-r--r-- | views/default/input/form.php | 62 |
1 files changed, 19 insertions, 43 deletions
diff --git a/views/default/input/form.php b/views/default/input/form.php index aed7a17bb..31c221688 100644 --- a/views/default/input/form.php +++ b/views/default/input/form.php @@ -8,55 +8,31 @@ * @subpackage Core * * @uses $vars['body'] The body of the form (made up of other input/xxx views and html - * @uses $vars['method'] Method (default POST) - * @uses $vars['enctype'] How the form is encoded, default blank - * @uses $vars['action'] URL of the action being called - * @uses $vars['js'] Any Javascript to enter into the form - * @uses $vars['internalid'] id for the form for CSS/Javascript - * @uses $vars['internalname'] name for the form for Javascript * @uses $vars['disable_security'] turn off CSRF security by setting to true */ -if (isset($vars['internalid'])) { - $id = $vars['internalid']; -} else { - $id = ''; -} +$defaults = array( + 'method' => "post", + 'disable_security' => FALSE, +); + +$vars = array_merge($defaults, $vars); -if (isset($vars['internalname'])) { - $name = $vars['internalname']; -} else { - $name = ''; -} $body = $vars['body']; -$action = elgg_normalize_url($vars['action']); -if (isset($vars['enctype'])) { - $enctype = $vars['enctype']; -} else { - $enctype = ''; -} -if (isset($vars['method'])) { - $method = $vars['method']; -} else { - $method = 'POST'; -} -if (isset($vars['class'])) { - $class = $vars['class']; -} else { - $class = ''; -} +unset($vars['body']); + +$vars['action'] = elgg_normalize_url($vars['action']); -$method = strtolower($method); +// @todo why? +$vars['method'] = strtolower($vars['method']); // Generate a security header -$security_header = ""; -if (!isset($vars['disable_security']) || $vars['disable_security'] != true) { - $security_header = elgg_view('input/securitytoken'); +if (!$vars['disable_security']) { + $body .= elgg_view('input/securitytoken'); } -?> -<form <?php if ($id) { ?>id="<?php echo $id; ?>" <?php } ?> <?php if ($name) { ?>name="<?php echo $name; ?>" <?php } ?> <?php echo $vars['js']; ?> action="<?php echo $action; ?>" method="<?php echo $method; ?>" <?php if ($enctype!="") echo "enctype=\"$enctype\""; ?> class="<?php echo $class; ?>"> -<fieldset> -<?php echo $security_header; ?> -<?php echo $body; ?> -</fieldset> -</form>
\ No newline at end of file +unset($vars['disable_security']); + + +$attributes = elgg_format_attributes($vars); + +echo "<form $attributes>$body</form>";
\ No newline at end of file |