summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-02-09 16:22:48 +0900
committerNathaniel Catchpole2016-02-09 16:22:48 +0900
commitde27f1970ab62ce7f040679907d0591dd3b644f6 (patch)
tree3a148fe3bf6d47236e02fc5e1350822279d7ff1d
parentd8cf1783df08229d4efd0b4c4f2fef848c01e98c (diff)
Issue #2587755 by aerozeppelin, NickWilde, swentel: AJAX error when using progress bar on file field widget
-rw-r--r--core/modules/file/file.routing.yml2
-rw-r--r--core/modules/file/src/Element/ManagedFile.php2
-rw-r--r--core/modules/file/src/Tests/FileFieldWidgetTest.php6
3 files changed, 8 insertions, 2 deletions
diff --git a/core/modules/file/file.routing.yml b/core/modules/file/file.routing.yml
index b7d2e6a..e182c97 100644
--- a/core/modules/file/file.routing.yml
+++ b/core/modules/file/file.routing.yml
@@ -1,5 +1,5 @@
file.ajax_progress:
- path: '/file/progress'
+ path: '/file/progress/{key}'
defaults:
_controller: '\Drupal\file\Controller\FileWidgetAjaxController::progress'
requirements:
diff --git a/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php
index 1d9a742..0077716 100644
--- a/core/modules/file/src/Element/ManagedFile.php
+++ b/core/modules/file/src/Element/ManagedFile.php
@@ -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.
diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php
index 7b0cce5..0e308df 100644
--- a/core/modules/file/src/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php
@@ -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...');
}
}