I've followed the Combine Dropzone With Normal Form tutorial to allow Dropzone uploads & form submit. The form is an application form, which should work both with & without files added. Currently it works only when one or more files are added to the Dropzone.
Is there an option I can enable to allow Dropzone to process the form submission even if the upload queue is empty?
Here's how I initialise the form:
Dropzone.options.general = {
paramName: 'tx_ddapplicationform_applicationformgeneral[form][files]', // The name that will be used to transfer the file
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
maxFiles: 100,
addRemoveLinks: true,
previewsContainer: '.dropzone-previews', // we specify on which div id we must show the files
clickable: false,
// The setting up of the dropzone
init: function() {
var myDropzone = this;
console.log(myDropzone)
console.log("Dropzone init");
console.log(this.element.querySelector("input[type=submit]"))
// First change the button to actually tell Dropzone to process the queue.
this.element.querySelector("input[type=submit]").addEventListener("click", function(e) {
// Make sure that the form isn't actually being sent.
console.log("the button is clicked")
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
console.log("after processQueue")
});
// Listen to the sendingmultiple event. In this case, it's the sendingmultiple event instead
// of the sending event because uploadMultiple is set to true.
this.on("sendingmultiple", function() {
console.log("sending multiple");
});
this.on("successmultiple", function(files, response) {
console.log("success multiple");
});
this.on("errormultiple", function(files, response) {
console.log("error multiple");
});
}
I went through the dropzone.js form and added console.logs to see what was going on. A successful submit (with a file added) logs this:
processQueue dropzone.js:1301
upload multiple dropzone.js:1314
sending multiple main.jquery.js:551
after processQueue main.jquery.js:545
success multiple main.jquery.js:554
An unsuccessful submit, without an attached file, logs this:
processQueue dropzone.js:1301
after processQueue main.jquery.js:545