Closed stretau closed 4 years ago
@stretau did you find a workaround for this? Facing the same issue
Stale issue
I am facing same issue. Please let me know if there is any workaround.
Possible solution:
updateValue(event) {
const lValues = event.value.map(item => {
return `${item}`;
}).join(',');
this.jsf.updateValue(this, `[${lValues}]`);
}
This method saves an array in jsf.data
Ended up doing below.
updateValue(event) { const formArray = this.jsf.getFormControl(this) as FormArray; if ((!event || event.length === 0) && formArray && formArray.controls) { while (formArray.controls.length > 0) { formArray.removeAt(0); } } this.jsf.updateValue(this, event); }
Describe the bug which template:
A clear and concise description of what the bug is.
To Reproduce It seems there is something broken with Updating the form value correctly when using array-types. But maybe I do sth. wrong
Eventually consider this PR in angular2-json-schema-form: https://github.com/dschnelldavis/angular2-json-schema-form/pull/304
I have written my own widget which use ng-select https://github.com/ng-select/ng-select:
This Component I successfully register as new Widget for angular6-json-schema-form. My ng-select component is rendered successfully. But if I activate the "multiple"-Option, the value in "updateValue" is an array. Because of this my Schema is like this:
If I add one value from ng-select. Everything is fine. The form value for inv_reason is an array which contains the first selected option. But if I add one more item, then console.log error occured with the following:
Expected behavior The array-value should be correct updated in the form.
I'm using Angular 6 and the latest version of this package here.
Thx in advance, Best Regards