aboutsummaryrefslogtreecommitdiff
path: root/views/default/input
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-20 06:23:06 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-20 06:23:06 +0000
commit1ec293a95a94e07cc8084aeca1b54dd3486e8895 (patch)
tree0292561dbcf25f01dd2d34f43e86891bce541296 /views/default/input
parent41f2f30040697cadc1d4759c9d2e6689bc26e788 (diff)
downloadelgg-1ec293a95a94e07cc8084aeca1b54dd3486e8895.tar.gz
elgg-1ec293a95a94e07cc8084aeca1b54dd3486e8895.tar.bz2
Refs #2143: DRYed up input/form
git-svn-id: http://code.elgg.org/elgg/trunk@7356 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/input')
-rw-r--r--views/default/input/form.php62
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