Change in FormJson dynamically doesn't update Form
See original GitHub issueHi,
I modified the ng2-formio start kit and added a button to update the form schema json.
<button class="btn btn-primary" (click)="addControl()"> Add Control </button>
`addControl() { var data = { ‘type’: ‘textfield’, ‘input’: true, ‘tableView’: true, ‘inputType’: ‘text’, ‘inputMask’: ‘’, ‘label’: ‘Last Name’, ‘key’: ‘lastName’, ‘placeholder’: ‘Enter your last name’, ‘prefix’: ‘’, ‘suffix’: ‘’, ‘multiple’: false, ‘defaultValue’: ‘’, ‘protected’: false, ‘unique’: false, ‘persistent’: true, ‘validate’: { ‘required’: true, ‘minLength’: 2, ‘maxLength’: 10, ‘pattern’: ‘’, ‘custom’: ‘’, ‘customPrivate’: false }, ‘conditional’: { ‘show’: ‘’, ‘when’: null, ‘eq’: ‘’ } };
this.formJson.components.push(data);
};`
It doesn’t update the form dynamically. Am I missing anything??
Thanks, Aniket
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
You can include an event emitter as an input to the
refresh
property like so.Then in your controller do the following.
@ahka01 , Thanks for the reply. The problem isn’t with updating the form and submission data. It works as expected. I’m talking about the form change event callback. If you inspect the object you get when form change event triggers, you’ll see previous as well as new form submission keys in the data object.