diff --git a/projects/ngx-formentry/src/abstract-controls-extension/afe-form-array.ts b/projects/ngx-formentry/src/abstract-controls-extension/afe-form-array.ts index 089036c6..524205e1 100644 --- a/projects/ngx-formentry/src/abstract-controls-extension/afe-form-array.ts +++ b/projects/ngx-formentry/src/abstract-controls-extension/afe-form-array.ts @@ -144,6 +144,8 @@ export class AfeFormArray } setValue(value: any) { - super.setValue(value); + if (value !== null) { + super.setValue(value); + } } } diff --git a/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.spec.ts b/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.spec.ts index 9a745f26..fc31a925 100644 --- a/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.spec.ts +++ b/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.spec.ts @@ -33,7 +33,8 @@ describe('Control Hider Helper Service:', () => { show: () => {}, hiders: [], updateHiddenState: () => {}, - setHidingFn: (newHider: Hider) => {} + setHidingFn: (newHider: Hider) => {}, + setValue: (value: any) => {} }; control.hide(); @@ -56,7 +57,8 @@ describe('Control Hider Helper Service:', () => { }, hiders: [], updateHiddenState: () => {}, - setHidingFn: (newHider: Hider) => {} + setHidingFn: (newHider: Hider) => {}, + setValue: (value: any) => {} }; control.show(); @@ -76,7 +78,8 @@ describe('Control Hider Helper Service:', () => { updateHiddenState: () => {}, setHidingFn: (newHider: Hider) => { helper.setHiderForControl(control, newHider); - } + }, + setValue: (value: any) => {} }; const hider: Hider = { @@ -103,7 +106,8 @@ describe('Control Hider Helper Service:', () => { show: () => {}, hiders: [], updateHiddenState: () => {}, - setHidingFn: (newHider: Hider) => {} + setHidingFn: (newHider: Hider) => {}, + setValue: (value: any) => {} }; const hider: Hider = { @@ -138,7 +142,8 @@ describe('Control Hider Helper Service:', () => { updateHiddenState: () => { helper.evaluateControlHiders(control); }, - setHidingFn: (newHider: Hider) => {} + setHidingFn: (newHider: Hider) => {}, + setValue: (value: any) => {} }; const hider1: Hider = { @@ -186,7 +191,8 @@ describe('Control Hider Helper Service:', () => { updateHiddenState: () => { helper.evaluateControlHiders(control2); }, - setHidingFn: (newHider: Hider) => {} + setHidingFn: (newHider: Hider) => {}, + setValue: (value: any) => {} }; const hider4: Hider = { @@ -230,7 +236,8 @@ describe('Control Hider Helper Service:', () => { helper.evaluateControlHiders(control); }, setHidingFn: (newHider: Hider) => {}, - valueChanges: subject.asObservable() + valueChanges: subject.asObservable(), + setValue: (value: any) => {} }; const hider1: Hider = { diff --git a/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.ts b/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.ts index 4b3dd1fa..4bc5c49a 100644 --- a/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.ts +++ b/projects/ngx-formentry/src/form-entry/control-hiders-disablers/hider-helpers.ts @@ -26,6 +26,7 @@ export class HiderHelper { hider.reEvaluateHidingExpression(); if (hider.toHide === true) { hiddenValue = true; + control.setValue(null); } }); diff --git a/projects/ngx-formentry/src/form-entry/value-adapters/obs.adapter.spec.ts b/projects/ngx-formentry/src/form-entry/value-adapters/obs.adapter.spec.ts index 23468209..9ab0b3be 100644 --- a/projects/ngx-formentry/src/form-entry/value-adapters/obs.adapter.spec.ts +++ b/projects/ngx-formentry/src/form-entry/value-adapters/obs.adapter.spec.ts @@ -411,8 +411,8 @@ describe('Obs Value Adapter: ', () => { expect(value['onArt']).toEqual('a899b35c-1350-11df-a1f1-0026b9348838'); expect(value['tbadhere']).toEqual({ tb_adherence: 'a8b0f882-1350-11df-a1f1-0026b9348838', - adherenceTbTreatment: '', - adherenceTbOther: '' + adherenceTbTreatment: null, + adherenceTbOther: null }); // check complex values