I am trying to update the Formly form rendering after making some changes in the form scheme (the array of FormlyFormConfig
objects). It works when I add a new object or if I change a field label, but it does not if I change the default value.
Here is a minimal reproducible example: https://stackblitz.com/edit/ngx-formly-ui-material-m8ntjc?file=src/app/app.component.ts
this.fields[0].props.label = 'new label'; // Updated
this.fields[0].defaultValue = 'new def val'; // NOT updated
this.fields.push({
key: 'cbx',
type: 'checkbox',
props: {
label: 'new cbx',
},
}); // Updated
this.options.build();
Found the answer by myself.
In reality, the default value was taken into account but it was overridden by the model. (The previous default had been stored there)
Reseting the model made the whole thing work: https://stackblitz.com/edit/ngx-formly-ui-material-g9a4st?file=src/app/app.component.ts