Replies: 1 comment
-
You can use trigger() to do that. For example, I'm using a custom selection component which I use to select the leaseID of a mandatory field, and I use onSelect (you could also use onChange) to retrigger the leaseID field. Here's an example: <FormField
control={paymentForm.control}
name="leaseId"
render={({field}) => (
<FormItem>
<FormLabel>Lease *</FormLabel>
<FormControl >
<LeaseSelection onSelect={(leaseId) => {
paymentForm.setValue('leaseId', leaseId)
setSelectedLease(leases?.data?.find((lease) => lease.id === leaseId))
paymentForm.trigger('leaseId')}}
selected={Number(paymentForm.getValues("leaseId"))} leases={leases?.data}
className="w-full"
/>
</FormControl>
<FormMessage/>
</FormItem>
)}
/> Here I'm specifically only retriggering the leaseId field, if you want to trigger all fields you can do so by just calling paymentForm.trigger() with no input. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just wondering how to trigger the Schema Validation without submit the form.
Examples are welcome.
Beta Was this translation helpful? Give feedback.
All reactions