From 3f01a92d67929f9d040cf70a91134b7693a126b8 Mon Sep 17 00:00:00 2001 From: Bartosz Sekula Date: Mon, 26 Jan 2026 10:21:00 +0100 Subject: [PATCH] AAE-34140 Asynchronous Forms - automatically populated value cannot be used in another task (#11574) * AAE-34140 Asynchronous Forms - automatically populated value cannot be used in another task * update * update --- .../widgets/core/form-field.model.spec.ts | 27 +++++++++++++++++++ .../widgets/core/form-field.model.ts | 10 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts b/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts index 91eb41beff..58650e2203 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field.model.spec.ts @@ -420,6 +420,33 @@ describe('FormFieldModel', () => { expect(formDateTimeFormatted).toEqual(currentDateTimeFormatted); }); + it('should handle properly date string that is in ISO format', () => { + const form = new FormModel(); + const field = new FormFieldModel(form, { + fieldType: 'FormFieldRepresentation', + id: 'date', + name: 'date', + type: FormFieldTypes.DATE, + value: '', + required: false, + readOnly: false, + params: { + field: { + id: 'date', + name: 'date', + type: FormFieldTypes.DATE, + value: '', + required: false, + readOnly: false + } + } + }); + + field.value = '2026-01-23T15:25:03.439+0000'; + + expect(field.getFormValue()).toEqual('2026-01-23T00:00:00.000Z'); + }); + it('should set the value to null when the value is null', () => { const form = new FormModel(); const field = new FormFieldModel(form, { diff --git a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts index b3e0249f6c..7a6f9e8927 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts @@ -681,7 +681,15 @@ export class FormFieldModel extends FormWidgetModel { let dateValue; try { - dateValue = DateFnsUtils.parseDate(this.value, this.dateDisplayFormat); + let dateWithProperFormat: string | Date; + + if (typeof this.value === 'string') { + dateWithProperFormat = DateFnsUtils.formatDate(this.value, this.dateDisplayFormat); + } else { + dateWithProperFormat = this.value; + } + + dateValue = DateFnsUtils.parseDate(dateWithProperFormat, this.dateDisplayFormat); } catch { dateValue = new Date('error'); }