]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2143: DRYed up input/form
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 06:23:06 +0000 (06:23 +0000)
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 20 Nov 2010 06:23:06 +0000 (06:23 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7356 36083f99-b078-4883-b0ff-0f9b5a30f544

views/default/input/form.php

index aed7a17bb7ef00312600c14d73887f0dd791a536..31c22168804d8e57123c7beefdc203cac7aa5775 100644 (file)
@@ -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