diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-02-10 05:25:57 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-02-10 05:25:57 +0000 |
commit | 583d5a4ee95a583184f39497a44062599ad6e1d7 (patch) | |
tree | cdefa73496e1140b7856f4a2fe869b5962b08eac /includes/form.inc | |
parent | 91152ba7af96b8f7125cc54a268f0056435908a1 (diff) | |
download | brdo-583d5a4ee95a583184f39497a44062599ad6e1d7.tar.gz brdo-583d5a4ee95a583184f39497a44062599ad6e1d7.tar.bz2 |
- Patch #48622 by adrian: remove drupal_goto from _submit functions.
Diffstat (limited to 'includes/form.inc')
-rw-r--r-- | includes/form.inc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/includes/form.inc b/includes/form.inc index 66159313f..fa2fdef49 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -103,11 +103,24 @@ function drupal_get_form($form_id, &$form, $callback = NULL) { } $form = _form_builder($form_id, $form); - + $goto = $_GET['q']; if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) { drupal_validate_form($form_id, $form, $callback); if ($form_submitted && !form_get_errors()) { - drupal_submit_form($form_id, $form, $callback); + $redirect = drupal_submit_form($form_id, $form, $callback); + if (!is_null($redirect)) { + $goto = $redirect; + } + else if ($form['#redirect']) { + $goto = $form['#redirect']; + } + + if (is_array($goto)) { + call_user_func_array('drupal_goto', $redirect); + } + else { + drupal_goto(drupal_get_path_alias($goto)); + } } } @@ -136,14 +149,18 @@ function drupal_validate_form($form_id, &$form, $callback = NULL) { function drupal_submit_form($form_id, $form, $callback = NULL) { global $form_values; + $goto = null; unset($GLOBALS['form_values']['submit'], $GLOBALS['form_values']['form_id']); if (isset($form['#submit'])) { foreach ($form['#submit'] as $function => $args) { if (function_exists($function)) { - call_user_func_array($function, $args); + // Since we can only redirect to one page, only the last redirect will work + $redirect = call_user_func_array($function, $args); + $goto = (!is_null($redirect)) ? $redirect : $goto; } } } + return $goto; } function _form_validate($elements, $form_id = NULL) { |