diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-09-13 01:09:26 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-09-13 01:09:26 +0000 |
commit | f8b63338e48a6b0ef52e024030b0330c0fc8af53 (patch) | |
tree | d411369da8a9110f6a3d715f325130e289d03713 /includes/ajax.inc | |
parent | 1b3c481ad151fff0fe22b1b00330c08e0244203b (diff) | |
download | brdo-f8b63338e48a6b0ef52e024030b0330c0fc8af53.tar.gz brdo-f8b63338e48a6b0ef52e024030b0330c0fc8af53.tar.bz2 |
- Patch #756762 by effulgentsia, fago, sun, rfay, pwolanin: AJAX should follow same rules for whether to call drupal_rebuild_form() as non-AJAX submissions.
Diffstat (limited to 'includes/ajax.inc')
-rw-r--r-- | includes/ajax.inc | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/includes/ajax.inc b/includes/ajax.inc index 49ff7e46b..e1ea518d7 100644 --- a/includes/ajax.inc +++ b/includes/ajax.inc @@ -239,6 +239,12 @@ function ajax_get_form() { // Since some of the submit handlers are run, redirects need to be disabled. $form_state['no_redirect'] = TRUE; + // When a form is rebuilt after AJAX processing, its #build_id and #action + // should not change. + // @see drupal_rebuild_form() + $form_state['rebuild_info']['copy']['#build_id'] = TRUE; + $form_state['rebuild_info']['copy']['#action'] = TRUE; + // The form needs to be processed; prepare for that by setting a few internal // variables. $form_state['input'] = $_POST; @@ -263,18 +269,15 @@ function ajax_get_form() { * enhanced function. */ function ajax_form_callback() { - list($form, $form_state, $form_id, $form_build_id) = ajax_get_form(); - - // Build, validate and if possible, submit the form. - drupal_process_form($form_id, $form, $form_state); - - // This call recreates the form relying solely on the $form_state that - // drupal_process_form() set up. - $form = drupal_rebuild_form($form_id, $form_state, $form); - - // As part of drupal_process_form(), the element that triggered the form - // submission is determined, and in the case of AJAX, it might not be a - // button. This lets us route to the appropriate callback. + list($form, $form_state) = ajax_get_form(); + drupal_process_form($form['#form_id'], $form, $form_state); + + // We need to return the part of the form (or some other content) that needs + // to be re-rendered so the browser can update the page with changed content. + // Since this is the generic menu callback used by many AJAX elements, it is + // up to the #ajax['callback'] function of the element (may or may not be a + // button) that triggered the AJAX request to determine what needs to be + // rendered. if (!empty($form_state['triggering_element'])) { $callback = $form_state['triggering_element']['#ajax']['callback']; } |