diff --git a/lib/core/form/components/widgets/core/form-field.model.spec.ts b/lib/core/form/components/widgets/core/form-field.model.spec.ts index afea033f31..53b079b3a7 100644 --- a/lib/core/form/components/widgets/core/form-field.model.spec.ts +++ b/lib/core/form/components/widgets/core/form-field.model.spec.ts @@ -612,6 +612,31 @@ describe('FormFieldModel', () => { expect(form.values['dropdown_field'].name).toEqual('Option 1'); }); + it('should parse and resolve people null value as null', () => { + const field = new FormFieldModel(new FormModel(), { + type: FormFieldTypes.PEOPLE, + value: null + }); + + field.updateForm(); + + expect(field.value).toBe(null); + }); + + it('should parse and resolve people undefined value as null', () => { + const field = new FormFieldModel(new FormModel(), { + fieldType: 'HeaderFieldtype', + id: 'people_field', + name: 'people', + type: FormFieldTypes.PEOPLE, + value: undefined + }); + + field.updateForm(); + + expect(field.value).toBe(null); + }); + describe('variables', () => { let form: FormModel; @@ -680,5 +705,6 @@ describe('FormFieldModel', () => { expect(field.value).toBe('default hello'); }); + }); }); diff --git a/lib/core/form/components/widgets/core/form-field.model.ts b/lib/core/form/components/widgets/core/form-field.model.ts index 24b8e7b2b4..78185fedb8 100644 --- a/lib/core/form/components/widgets/core/form-field.model.ts +++ b/lib/core/form/components/widgets/core/form-field.model.ts @@ -268,7 +268,7 @@ export class FormFieldModel extends FormWidgetModel { } parseValue(json: any): any { - let value = json.hasOwnProperty('value') ? json.value : null; + let value = json.hasOwnProperty('value') && json.value !== undefined ? json.value : null; /* This is needed due to Activiti issue related to reading dropdown values as value string @@ -408,10 +408,10 @@ export class FormFieldModel extends FormWidgetModel { this.form.values[this.id] = (this.value !== null && this.value !== undefined) ? this.value : false; break; case FormFieldTypes.PEOPLE: - this.form.values[this.id] = (this.value !== null && this.value !== undefined) ? this.value : []; + this.form.values[this.id] = this.value ? this.value : null; break; case FormFieldTypes.FUNCTIONAL_GROUP: - this.form.values[this.id] = (this.value !== null && this.value !== undefined) ? this.value : []; + this.form.values[this.id] = this.value ? this.value : null; break; default: if (!FormFieldTypes.isReadOnlyType(this.type) && !this.isInvalidFieldType(this.type)) {