Closed jfbloom22 closed 6 years ago
Hey buddy,
You don't need an another control userForm
, FormGenerator will create a control itself if no control is defined in fieldConfig
explicitly.
So you can just define a control like that:
import { AbstractControl } from 'react-reactive-form';
...
export default class UserForm extends React.Component<Iprops, Istate> {
public userForm: AbstractControl
....
awesome works perfectly! thx @bietkul!
I was about to switch an entire project from React to Angular for the model based forms. I thought maybe I could write a React form builder and follow the patterns in Angular... then I found this plugin! Whooohooo!
My question is how to properly use the FormGenerator with Typescript.
If I follow the example in the Readme, Typescript gives me this error:
Property 'userForm' does not exist on type 'UserForm'
. (it is calledloginForm
in the Readme) So I define it like this:this.userForm
is replaced with the dynamically generated form whenthis.setForm
runs and everything appears to be working great. Is this the best way to write this?full component: