Add controls to FormGenerator onMount?
bostondevin opened this issue · 2 comments
bostondevin commented
Is there a way to do this when the form mounts so I can add form fields to the form dynamically?
const config = {
controls: {},
};
const mountForm = (f) => {
f.addControl("firstName", Input); // This doesn't work...
f.addControl("lastName", Input); // This doesn't work...
};
return (
<Form className="grid grid-cols-2 gap-2 p-2">
<FormGenerator onMount={mountForm} fieldConfig={config} />
</Form>
);
bietkul commented
@bostondevin No, it is not possible. The second option in addControl
method should be an instance of FormGroup
, FormControl
or FormArray
classes.
bostondevin commented
Thanks! I figured it out with just changing the config around of the FormBuilder