From c5537bf44421a52fe4beb4d52cbbcf4270be2772 Mon Sep 17 00:00:00 2001 From: Alexey Romanoff Date: Fri, 21 Jan 2022 12:57:20 +0300 Subject: [PATCH] fix(ajsf/core): json-schema-form service: initializeControl: fix null values in enum fromControl-s force formControl value to empty string when it's null and if the control has enum Fixes #333 --- projects/ajsf-core/src/lib/json-schema-form.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/ajsf-core/src/lib/json-schema-form.service.ts b/projects/ajsf-core/src/lib/json-schema-form.service.ts index a20eaa77..dfe2897c 100755 --- a/projects/ajsf-core/src/lib/json-schema-form.service.ts +++ b/projects/ajsf-core/src/lib/json-schema-form.service.ts @@ -544,6 +544,10 @@ export class JsonSchemaFormService { ctx.formControl = this.getFormControl(ctx); ctx.boundControl = bind && !!ctx.formControl; if (ctx.formControl) { + if (ctx.options.enum && ctx.formControl.value === null) { + ctx.formControl.value = ''; + } + ctx.controlName = this.getFormControlName(ctx); ctx.controlValue = ctx.formControl.value; ctx.controlDisabled = ctx.formControl.disabled;