diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/file/file.module | 10 | ||||
-rw-r--r-- | modules/simpletest/tests/form.test | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/modules/file/file.module b/modules/file/file.module index 1388f179b..5d76b6c82 100644 --- a/modules/file/file.module +++ b/modules/file/file.module @@ -254,7 +254,7 @@ function file_ajax_upload() { return array('#type' => 'ajax', '#commands' => $commands, '#header' => FALSE); } - list($form, $form_state, $form_id, $form_build_id) = ajax_get_form(); + list($form, $form_state) = ajax_get_form(); if (!$form) { // Invalid form_build_id. @@ -271,12 +271,8 @@ function file_ajax_upload() { } $current_file_count = isset($current_element['#file_upload_delta']) ? $current_element['#file_upload_delta'] : 0; - // 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 the - // drupal_process_form() set up. - $form = drupal_rebuild_form($form_id, $form_state, $form); + // Process user input. $form and $form_state are modified in the process. + drupal_process_form($form['#form_id'], $form, $form_state); // Retrieve the element to be rendered. foreach ($form_parents as $parent) { diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index d628f488b..ce4bc9681 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -1011,6 +1011,10 @@ class FormsRebuildTestCase extends DrupalWebTestCase { $this->drupalPost(NULL, array(), t('Save')); $this->assertText('Title field is required.', t('Non-AJAX submission correctly triggered a validation error.')); + // Ensure that the form contains two items in the multi-valued field, so we + // know we're testing a form that was correctly retrieved from cache. + $this->assert(count($this->xpath('//form[contains(@id, "page-node-form")]//div[contains(@class, "form-item-field-ajax-test")]//input[@type="text"]')) == 2, t('Form retained its state from cache.')); + // Ensure that the form's action is correct. $forms = $this->xpath('//form[contains(@class, "node-page-form")]'); $this->assert(count($forms) == 1 && $forms[0]['action'] == url('node/add/page'), t('Re-rendered form contains the correct action value.')); |