-
Hi, thanks for this great library! We're using the Zod resolver for validation. When we use it with a simple static form, the default validation behavior works as documented in However, when we use the Zod resolver with Is this expected? If so, how can we effectively achieve the same behavior as the default behavior for static forms; that is, start with |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
can you share a codesandbox on this? |
Beta Was this translation helpful? Give feedback.
-
My apologies: as I mentioned, I'm inexperienced with codesandbox, but I can't figure out how to import a public GitHub repo into a sandbox without giving codesandbox permissions to read and write private repos, which I'm unwilling to do. I have, however, created a simple project that reproduces the issue: https://github.com/hackworthltd/rhf-reproducer The simple static form there does what I want: it does not validate until submit, then sets The dynamic form using Note that I was able to reproduce this without even using Zod validation, just the built-in validation, so this does not appear to be related to Zod. I've changed the title of the discussion to reflect that. I'm probably doing something dumb, but any help here pointing out my mistake would be welcome. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Your "Add" button does not set attribute Just add attribute |
Beta Was this translation helpful? Give feedback.
@dhess
Your "Add" button does not set attribute
type
, therefore,type="submit"
will be the default attribute of HTML Button element and causesonSubmit
event handler to be triggered because "Add" is now a submit button.Just add attribute
type="button"
to solve this problem.