From 1ec293a95a94e07cc8084aeca1b54dd3486e8895 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Sat, 20 Nov 2010 06:23:06 +0000 Subject: Refs #2143: DRYed up input/form git-svn-id: http://code.elgg.org/elgg/trunk@7356 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/input/form.php | 62 ++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 43 deletions(-) (limited to 'views') 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'); } -?> -
id="" name="" action="" method="" class=""> -
- - -
-
\ No newline at end of file +unset($vars['disable_security']); + + +$attributes = elgg_format_attributes($vars); + +echo "
$body
"; \ No newline at end of file -- cgit v1.2.3