From e0a9e402c518a5f763827b133dc3238399af4ad1 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 14 Nov 2023 11:15:27 +0100 Subject: [PATCH] [CST-12190] Fix issue with authority enrichment which didn't find the proper model to enrich --- src/app/shared/form/builder/form-builder.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/shared/form/builder/form-builder.service.ts b/src/app/shared/form/builder/form-builder.service.ts index 47c71ebb543..d24582c22d7 100644 --- a/src/app/shared/form/builder/form-builder.service.ts +++ b/src/app/shared/form/builder/form-builder.service.ts @@ -505,9 +505,10 @@ export class FormBuilderService extends DynamicFormService { */ updateModelValue(fieldId: string, value: FormFieldMetadataValueObject): DynamicFormControlModel { let returnModel = null; - this.formModels.forEach((models, formId) => { + [...this.formModels.keys()].find((formId) => { + const models = this.formModels.get(formId); const fieldModel: any = this.findById(fieldId, models); - if (hasValue(fieldModel)) { + if (hasValue(fieldModel) && !fieldModel.hidden) { if (isNotEmpty(value)) { if (fieldModel.repeatable && isNotEmpty(fieldModel.value)) { // if model is repeatable and has already a value add a new field instead of replacing it @@ -527,8 +528,9 @@ export class FormBuilderService extends DynamicFormService { returnModel = fieldModel; } } - return; + return returnModel; } + return false; }); return returnModel; }