angular
angular copied to clipboard
[Question] Were there changes to how data should be loaded into the form?
Hi,
Until now I was loading data into the form in (render) method by setting them like this: this.formio.formio.submission.data = myDataObject (where this.formio is a viewchild FormioComponent that is not static). I updated the Angular to 9 and formio as well (now I have "angular-formio": "^4.7.4" and "formiojs": "^4.9.17") and now this piece of code is causing the data to appear and disappear right after. The submission object appears to be cleared later. Is there some change to how data should be loaded into the form?
I too have this issue. It looks like a bug to me.
In my case, I'm loading multiple forms as Material tabs, and want to pre-populate the values to make a RESTful configuration UI. The Form has been mutating my submission
object, and refuses to take the values that I try to prepopulate.
I was able to get it working with the following "hack".
Component.html:
...
<mat-tab *ngFor="let schema of configSchemas" [label]="schema.file">
<mat-formio [submission]="{data: schema.config}" (submissionLoad)="render($event, aG(schema.sConfig))" [form]="schema.schema" (submit)="saveConfiguration($event)"></mat-formio>
</mat-tab>
...
Component.ts
...
aG(f){
return JSON.parse(f);
}
render(a: any, b: any){
a.data = b;
}
...
In my case, the schema
is an object like so:
{
schema: <FormIO JSON>,
file: <FormIO JSON File Path>,
config: <Stored Configuration>
}
We're currently addressing a backlog of GitHub issues, and as part of this effort, some inactive issues may be marked as closed. This isn't a dismissal, but a step toward more efficient tracking.
If you feel the issue is still relevant, please re-open and we'll ensure it gets the attention it deserves. Your understanding is appreciated as we work to enhance our open-source responsiveness.