From c327b4d407c0fc3ea74037789214b23d2b35e9a0 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 26 Mar 2010 18:58:12 +0000 Subject: - Patch #684846 by effulgentsia, rfay, quicksketch, aspilicious: AJAX triggered by non-submit element fails if any elements are validated. --- modules/file/file.module | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'modules/file') diff --git a/modules/file/file.module b/modules/file/file.module index d0f95cfb8..0eba84715 100644 --- a/modules/file/file.module +++ b/modules/file/file.module @@ -385,12 +385,12 @@ function file_managed_file_process($element, &$form_state, $form) { '#weight' => -5, ); - // Because the output of this field changes depending on the button clicked, - // we need to ask FAPI immediately if the remove button was clicked. - // It's not good that we call this private function, but - // $form_state['clicked_button'] is only available after this #process - // callback is finished. - if (_form_button_was_clicked($element['remove_button'], $form_state)) { + // @todo It is not good to call these private functions. This should be + // refactored so that the file deletion happens during a submit handler, + // and form changes affected by that (such as toggling the upload and remove + // buttons) happens during the 2nd run of this function that is triggered by + // a form rebuild: http://drupal.org/node/736298. + if (_form_button_was_clicked($element['remove_button'], $form_state) || _form_element_triggered_scripted_submission($element['remove_button'], $form_state)) { // If it's a temporary file we can safely remove it immediately, otherwise // it's up to the implementing module to clean up files that are in use. if ($element['#file'] && $element['#file']->status == 0) { -- cgit v1.2.3