Issue #2587755 by aerozeppelin, NickWilde, swentel: AJAX error when using progress bar on file field widget

8.1.x
Nathaniel Catchpole 2016-02-09 16:22:48 +09:00
parent d8cf1783df
commit de27f1970a
3 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,5 @@
file.ajax_progress:
path: '/file/progress'
path: '/file/progress/{key}'
defaults:
_controller: '\Drupal\file\Controller\FileWidgetAjaxController::progress'
requirements:

View File

@ -271,7 +271,7 @@ class ManagedFile extends FormElement {
}
// Add the upload progress callback.
$element['upload_button']['#ajax']['progress']['url'] = Url::fromRoute('file.ajax_progress');
$element['upload_button']['#ajax']['progress']['url'] = Url::fromRoute('file.ajax_progress', ['key' => $upload_progress_key]);
}
// The file upload field itself.

View File

@ -447,6 +447,12 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// If the field has at least a item, the table should be visible.
$this->assertIdentical(count($elements), 1);
// Test for AJAX error when using progress bar on file field widget
$key = $this->randomMachineName();
$this->drupalPost('file/progress/' . $key, 'application/json', []);
$this->assertNoResponse(500, t('No AJAX error when using progress bar on file field widget'));
$this->assertText('Starting upload...');
}
}