formio / ngFormio

JSON powered form rendering library for AngularJS + Form.io.
http://formio.github.io/ngFormio/
MIT License
99 stars 102 forks source link

Populate data in form builder #736

Closed AbdelWahedHamed closed 1 month ago

AbdelWahedHamed commented 1 month ago

Describe the bug I am using the form builder code in an angular project and I made a JSON for a form to show it before I drag or drop any components, like the form is already there and I can use form builder on it, I need to know if is there is a way to populate this form with data

Additional context the HTML code

<form-builder [form]="form" >

the ts code

formComponents: any = [ { label: "Text Field", applyMaskOn: "change", tableView: true, validateWhenHidden: false, key: "1", type: "textfield", input: true,

}, { label: "Checkbox", tableView: false, validateWhenHidden: false, key: "checkbox", type: "checkbox", input: true }, { label: "Text Area", applyMaskOn: "change", autoExpand: false, tableView: true, validateWhenHidden: false, key: "textArea", type: "textarea", input: true }, ];

constructor(public auth: FormioAuthService) {} ngOnInit(): void { this.form = { components: this.formComponents, };

}

AbdelWahedHamed commented 1 month ago

I found a way is to add "defaultValue" to the JSON