diff --git a/app/frontend/src/components/designer/FormViewerMultiUpload.vue b/app/frontend/src/components/designer/FormViewerMultiUpload.vue index 3aa56c5dc..bc3faac46 100644 --- a/app/frontend/src/components/designer/FormViewerMultiUpload.vue +++ b/app/frontend/src/components/designer/FormViewerMultiUpload.vue @@ -140,6 +140,7 @@ import { mapActions } from 'vuex'; import { Formio, Utils } from 'vue-formio'; // import { nextTick } from 'process'; +import _ from 'lodash'; export default { name: 'FormViewerDownloadButton', components: {}, @@ -432,6 +433,22 @@ export default { } return time; }, + convertEmptyArraysToNull(obj) { + /* + * This function is purely made to solve this https://github.com/formio/formio.js/issues/4515 formio bug + * where setSubmission mislead payload for submission. In our case if setSubmission got triggered multiple + * time it cache submission key's with old values that leads to trigger false validation errors. + * This function clear object with some empty arrays to null. Main problem was occured to columns and grids components. + */ + + if (_.isArray(obj)) { + return obj.length === 0 ? null : obj.map(this.convertEmptyArraysToNull); + } else if (_.isObject(obj)) { + return _.mapValues(obj, this.convertEmptyArraysToNull); + } else { + return obj; + } + }, async validate(element, errors) { await this.delay(500); //this.checkMemoryUsage(); @@ -485,7 +502,7 @@ export default { async formIOValidation(element) { return new Promise((resolve) => { this.vForm.setSubmission({ - data: element, + data: this.convertEmptyArraysToNull(element), }); this.vForm .submit()