diff --git a/frontend/src/utils/form/datepicker.js b/frontend/src/utils/form/datepicker.js index 78e21ec02..7ee691ccf 100644 --- a/frontend/src/utils/form/datepicker.js +++ b/frontend/src/utils/form/datepicker.js @@ -112,4 +112,20 @@ export class Datepicker { if (!this.datepickerInstance.select || !this._element.value) return; this._element.value = dateFormat(this.datepickerInstance.select, FORM_DATE_FORMAT); } + + /** + * Calls formatElementValue on all datepicker objects registered for a form. + * @param {*} formID ID of the form for which all datepicker date values should be formatted + */ + static formatAllFormElementValues(formID) { + if (!Datepicker.datepickerCollections) { + // no datepicker collections yet (i.e. constructor was never called) => do nothing + return; + } + + if (Datepicker.datepickerCollections.has(formID)) { + const datepickerInstances = Datepicker.datepickerCollections.get(formID); + datepickerInstances.forEach(instance => instance.formatElementValue()); + } + } } \ No newline at end of file diff --git a/frontend/src/utils/mass-input/mass-input.js b/frontend/src/utils/mass-input/mass-input.js index 87d17c8c3..09d6d5aeb 100644 --- a/frontend/src/utils/mass-input/mass-input.js +++ b/frontend/src/utils/mass-input/mass-input.js @@ -1,4 +1,5 @@ import { Utility } from '../../core/utility'; +import { Datepicker } from '../form/datepicker'; const MASS_INPUT_CELL_SELECTOR = '.massinput__cell'; const MASS_INPUT_ADD_CELL_SELECTOR = '.massinput__cell--add'; @@ -95,6 +96,9 @@ export class MassInput { return false; } + // format any date values before submission + Datepicker.formatAllFormElementValues(this._massInputForm.id); + event.preventDefault(); const requestBody = this._serializeForm(submitButton, enctype);