Add formRef prop support
Hey there,
This is an awesome library and simplified my work to create forms way faster, eliminating all the boilerplate code required.
However, a quick question or may be something I am missing from docs, not sure.
Is it possible to submit the form from an external button ?
My use case:
- I have a zod schema and attached to AutoForm with the ZodProvider
- The form is rendering inside a Dialog and Dialog is having the Save and Cancel buttons
- I want to submit the form from the Save button in Dialog.
- Been trying from couple of hours, but not able to trigger the submit from outside, the problem is with validations not firing, as per the Zod schema validation. Let me know if I'm missing something or if there's an alternate / better way to achieve what I'm trying to do, or let me know if it doesn't work out this way.
Is withSubmit the only way to trigger field validations ?
I think it would be good to add support for a formRef prop to allow doing this easily.
For now you can try using the "onFormInit" prop to get access to the react-hook-form instance (https://autoform.vantezzen.io/docs/react/api#onforminit-form-forminstance--void) - but I don't know if there is some way to submit the form with that
Place the buttons inside the AutoForm as children with correct type like submit
https://codesandbox.io/p/github/adityacodepublic/project2/main?import=true