createForm
A utility that creates a closure that encapsulates all the functionality of react-hook-form
’s useForm
hook and zod
.
Props
zodSchema
- Defines the validation schema of your form using
"z" object from zod
. This will also enables typescript type safety and code auto complete specially while using the ctx object.
Returns
forwardFormContext
- Wraps your form component and injects the ctx object to the second parameter
(just like the react's forwardRef)
. - Adds optional
onInitializedFormContext
prop to wrapped component.
withFieldContext
- Wraps custom field component and pass appropriate props such as “register” or “control” and “error”.
- Adds type safety / auto complete to name prop.
- Requirements;
- Field component that will be wrap must have “register” or “control” and “name” props.
- OtherCustomFields (If you use createGeekFormInstace)