summaryrefslogtreecommitdiff
path: root/includes/form.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/form.inc')
-rw-r--r--includes/form.inc61
1 files changed, 15 insertions, 46 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 4dd5b9445..10c344712 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -29,8 +29,8 @@
* presentation, while simplifying code and reducing the amount of HTML that
* must be explicitly generated by modules.
*
- * The drupal_get_form() function handles retrieving, processing, and
- * displaying a rendered HTML form for modules automatically. For example:
+ * The drupal_get_form() function handles retrieving and processing an HTML
+ * form for modules automatically. For example:
*
* @code
* // Display the user registration form.
@@ -62,7 +62,7 @@
* example, the node_edit form requires that a node object is passed in here
* when it is called.
* @return
- * The rendered form.
+ * The form array.
*
* @see drupal_build_form()
*/
@@ -78,12 +78,11 @@ function drupal_get_form($form_id) {
}
/**
- * Build, render, and process a form based on a form id.
+ * Build and process a form based on a form id.
*
* The form may also be retrieved from the cache if the form was built in a
* previous page-load. The form is then passed on for processing, validation
- * and submission if there is proper input, and then rendered for display
- * if necessary.
+ * and submission if there is proper input.
*
* @param $form_id
* The unique string identifying the desired form. If a function with that
@@ -107,13 +106,6 @@ function drupal_get_form($form_id) {
* forms do not use form ids so are always considered to be submitted, which
* can have unexpected effects. The 'get' method should only be used on
* forms that do not change data, as that is exclusively the domain of post.
- * - rerender: May be set to FALSE to force the form to not be re-rendered
- * after submit. Ordinarily, forms are re-rendered after a successful submit
- * if there is no redirect. However, many forms may want to perform some
- * other action, but not necessarily re-render the form. This is
- * particularly true when using AHAH or AJAX where some data may be returned
- * to the calling JavaScript. Note that a form validation error will always
- * re-render the form.
* - no_redirect: If set to TRUE the form will NOT perform a drupal_goto(),
* even if a redirect is set.
* - always_process: If TRUE and the method is GET, a form_id is not
@@ -181,10 +173,6 @@ function drupal_build_form($form_id, &$form_state) {
// altering the $form_state variable, which is passed into them by
// reference.
drupal_process_form($form_id, $form, $form_state);
- // If we were told not to redirect, but not told to re-render, return here.
- if (!empty($form_state['executed']) && empty($form_state['rerender'])) {
- return;
- }
if ($cacheable && !empty($form['#cache']) && empty($form['#no_cache'])) {
// Caching is done past drupal_process_form so #process callbacks can
@@ -210,10 +198,17 @@ function drupal_build_form($form_id, &$form_state) {
if ((!empty($form_state['storage']) || !empty($form_state['rebuild'])) && !empty($form_state['submitted']) && !form_get_errors()) {
$form = drupal_rebuild_form($form_id, $form_state);
}
+
+ // Don't override #theme if someone already set it.
+ if (!isset($form['#theme'])) {
+ init_theme();
+ $registry = theme_get_registry();
+ if (isset($registry[$form_id])) {
+ $form['#theme'] = $form_id;
+ }
+ }
- // If we haven't redirected to a new location by now, we want to
- // render whatever form array is currently in hand.
- return drupal_render_form($form_id, $form);
+ return $form;
}
/**
@@ -224,7 +219,6 @@ function form_state_defaults() {
'storage' => NULL,
'submitted' => FALSE,
'method' => 'post',
- 'rerender' => TRUE,
'programmed' => FALSE,
'groups' => array(),
);
@@ -679,31 +673,6 @@ function drupal_validate_form($form_id, $form, &$form_state) {
}
/**
- * Renders a structured form array into themed HTML.
- *
- * @param $form_id
- * A unique string identifying the form for validation, submission,
- * theming, and hook_form_alter functions.
- * @param $form
- * An associative array containing the structure of the form.
- * @return
- * A string containing the themed HTML.
- */
-function drupal_render_form($form_id, &$form) {
- // Don't override #theme if someone already set it.
- if (!isset($form['#theme'])) {
- init_theme();
- $registry = theme_get_registry();
- if (isset($registry[$form_id])) {
- $form['#theme'] = $form_id;
- }
- }
-
- $output = drupal_render($form);
- return $output;
-}
-
-/**
* Redirect the user to a URL after a form has been processed.
*
* @param $form