Problem/Motivation

After update webform to the latest version, I can see that webform dropzonejs element does not work.

Proposed resolution

It seems like the depending library from the dropzonejs module was choosen wrongly.

CommentFileSizeAuthor
#4 3012550-wrong_library-4.patch347 bytesytsurk

Comments

lamp5 created an issue. See original summary.

krzysztof domański’s picture

I have the same problem (Webform 8.x-5.0-rc26). I checked the history of the Webform module!

Notice: All examples in this comment are for the Webform module.

Webform DropzoneJS worked at that time:

commit 61ff5698a844c5fa6e8a3bd2ace7ccb6217aa149
Date:   Fri Nov 2 02:25:12 2018 -0400

    Add missing libraries to composer.libaries.json.

Webform DropzoneJS has stopped working after commit issue #3010084.

commit ccc727c4f8fa41b989c719aeb8aa7f707bc13cc4
Date:   Sat Nov 3 06:40:25 2018 -0400

    Issue #3010084 by jrockowitz, jasonrust: Form submission finishes before file upload is complete

commit 993ca2e2d794bb3323101b1890e8f21d644a9f34
Date:   Sat Nov 3 06:40:40 2018 -0400

    Issue #3010084 by jrockowitz, jasonrust: Form submission finishes before file upload is complete

I analyzed. The problem is commit 993ca2e2d794bb3323101b1890e8f21d644a9f34.

--- a/src/Plugin/WebformElement/WebformManagedFileBase.php
+++ b/src/Plugin/WebformElement/WebformManagedFileBase.php
@@ -309,6 +309,11 @@ abstract class WebformManagedFileBase extends WebformElementBase implements Webf

     // Add after build handler.
     $element['#after_build'][] = [get_class($this), 'afterBuildManagedFile'];
+
+    // Add managed file upload tracking.
+    if (\Drupal::moduleHandler()->moduleExists('file')) {
+      $element['#attached']['library'][] = 'webform/webform.element.managed_file';
+    }
   }

Important: The contents of the scripts file (webform.element.managed_file) do not matter. I've attached an empty file and Webform DropzoneJS also does not work:

-      $element['#attached']['library'][] = 'webform/webform.element.managed_file';
+      $element['#attached']['library'][] = 'webform/webform.element.empty_scripts';

I don't know why, but attaching anything causes a problem.

krzysztof domański’s picture

There are no logs in the watchdog reports.

ytsurk’s picture

StatusFileSize
new347 bytes

I got it all working just by using a different library from dropzone. So this is not webform related ..

Try this patch - don't forget to rebuild the cache after applying it!

ytsurk’s picture

Status: Active » Needs review
Issue tags: -webform
ytsurk’s picture

Title: Webform DropzoneJS do not work with webform-5.0.0-rc25 + » Webform DropzoneJS is not initializing
Issue summary: View changes
lamp5’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @ytsurk for your work and patch. I tested it with webform 5.1.0 and can confirm that working good. +1 to RTBC

malcomio’s picture

Patch seems to do the trick with webform 5.1.0 as far as I can see

  • 3f634fd committed on 8.x-1.x
    Issue #3012550 by lamp5,krzysztof-domański,ytsurk,malcomio: Support...
chrisroane’s picture

Status: Reviewed & tested by the community » Fixed

I took a look at this problem. The patch fixed the core issue, but I noticed other problems. I updated the code and confirmed things work with the latest webform module, including webform 5.3-beta1. I also tested with the latest dropzonejs code and module.

The latest code also includes a fix to get the admin to work with the dropzone field correctly. You can now add/delete files in a dropzone field in submissions, and when you update the submission, it will not clear out the files on this field.

chrisroane’s picture

Status: Fixed » Closed (fixed)