diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-08-25 15:48:11 -0700 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-08-25 15:48:11 -0700 |
commit | 79bc4476464e53d38a36f59f9a438f7592215951 (patch) | |
tree | c603674ae1ff4fe8bab142414c6acbbd824bbab8 | |
parent | f97dad2d27466b7e80bb7bd150da6aad8dd804b2 (diff) | |
download | elgg-79bc4476464e53d38a36f59f9a438f7592215951.tar.gz elgg-79bc4476464e53d38a36f59f9a438f7592215951.tar.bz2 |
Fixes #3535. elgg_view_form() automatically adds elgg-form-action-name.
-rw-r--r-- | engine/lib/views.php | 14 |
1 files changed, 13 insertions, 1 deletions
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 <form> 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 * <code>echo elgg_view_form('login');</code> * @@ -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)); } |