So I have this long complex form (I'll just make it short)
<form>
<section>
<input type="text" name="customer" id="customer">
<input type="text" name="address" id="address">
<input type="text" name="contact_number" id="contact_number">
</section>
<section>
<input type="text" name="product_name[]" class="product_name">
<input type="text" name="qty[]" class="qty">
<input type="text" name="brand[]" class="brand">
<input type="text" name="model[]" class="model">
<div class="file_upload"></div>
<button type="submit" id="submit_btn">Submit Form</button>
</section>
</form>
and I am using DropzoneJS for uploading files. the problem here is that I need to pass the form fields values especially the ones with the inputs with array of name attributes.
here's my JS code so far:
var myDropzone = new Dropzone("div.file_upload", {
url: upload,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
autoProcessQueue: false,
addRemoveLinks: true,
uploadMultiple: true,
parallelUploads: 100,
maxFiles: 100,
maxFilesize: 500,
paramName: "file",
init: function(){
this.on("sendingmultiple", function(data, xhr, formData) {
formData.append("product_name", $(".product_name").serialize());
formData.append("qty", $(".qty").serialize());
formData.append("brand", $(".brand").serialize());
formData.append("model", $(".model").serialize());
formData.append("customer", $("#customer").val());
formData.append("address", $("#address").val());
formData.append("contact_number", $("#contact_number").val());
});
this.on("successmultiple", function(files, response) {
console.log('success sending')
});
this.on("errormultiple", function(files, response) {
console.log('error sending')
});
}
});
$("#submit_btn").click(function(e) {
e.preventDefault();
e.stopPropagation();
myDropzone.processQueue();
});
when i click the submit button I got an error in the console saying
$(...).processQueue is not a function
also, am I doing it right on sending the name arrays on my backend??
I use serialize() for each class..