Skip to main content

FormComponent

FormComponent

This is the component returned via createSchemaForm

Props

PropReqTypeDescription
schemaYesAnyZodObjectA zod object that will be used to validate your form input.
onSubmitYes(schema: DataType)=>voidA function that will be called when the form is submitted and validated successfully.
propsMaybeRecord<string, ComponentProps>props to pass to your components. Will be required if any of your components have required props, optional otherwise.
formPropsMaybeFormPropsprops to pass to your form, typesafe to your form component props.
defaultValuesNoDeepPartial<DataType>Default values for your form.
renderAfterNo({submit}:{submit: ()=>void})=>ReactNodeA function that returns an element to be rendered after your form inputs, inside the form container. Is passed the submit function that will try to submit the form.
renderBeforeNo({submit}:{submit: ()=>void})=>ReactNodeA function that returns an element to be rendered before your form inputs, inside the form container. Is passed the submit function that will try to submit the form.
formNoUseFormReturnOptionally pass a react-hook-form useForm() result so that you can have control of your form state in the parent component.