From 79bc4476464e53d38a36f59f9a438f7592215951 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Thu, 25 Aug 2011 15:48:11 -0700 Subject: Fixes #3535. elgg_view_form() automatically adds elgg-form-action-name. --- engine/lib/views.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'engine/lib/views.php') diff --git a/engine/lib/views.php b/engine/lib/views.php index fe3265347..68c1badbc 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1224,6 +1224,9 @@ function elgg_view_river_item($item, array $vars = array()) { * sets the action by default to "action/$action". Automatically wraps the forms/$action * view with a
tag and inserts the anti-csrf security tokens. * + * @tip This automatically appends elgg-form-action-name to the form's class. It replaces any + * slashes with dashes (blog/save becomes elgg-form-blog-save) + * * @example * echo elgg_view_form('login'); * @@ -1253,9 +1256,18 @@ function elgg_view_form($action, $form_vars = array(), $body_vars = array()) { $defaults = array( 'action' => $CONFIG->wwwroot . "action/$action", - 'body' => elgg_view("forms/$action", $body_vars), + 'body' => elgg_view("forms/$action", $body_vars) ); + $form_class = 'elgg-form-' . preg_replace('/[^a-z0-9]/i', '-', $action); + + // append elgg-form class to any class options set + if (isset($form_vars['class'])) { + $form_vars['class'] = $form_vars['class'] . " $form_class"; + } else { + $form_vars['class'] = $form_class; + } + return elgg_view('input/form', array_merge($defaults, $form_vars)); } -- cgit v1.2.3