Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate: After triggering form validation once, any subsequent forms added using the insert method will immediately trigger validation. #271

Open
qingzhoufeihu opened this issue Dec 3, 2024 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@qingzhoufeihu
Copy link

In the "todos" example in the playground, after clicking the submit button to trigger validation, if you click the add button, the newly added item automatically triggers validation. How can we avoid this validation?

https://modularforms.dev/react/playground/todos

step 1: click submit button
step2: click add new button

@qingzhoufeihu qingzhoufeihu changed the title After triggering form validation once, any subsequent forms added using the insert method will immediately trigger validation. Validate: After triggering form validation once, any subsequent forms added using the insert method will immediately trigger validation. Dec 3, 2024
@fabian-hiller
Copy link
Owner

Currently you can only avoid it by changing the revalidateOn option of useForm or createForm to 'submit'. What is your use case? Can't you enter a valid value when calling insert?

@fabian-hiller fabian-hiller self-assigned this Dec 4, 2024
@fabian-hiller fabian-hiller added the question Further information is requested label Dec 4, 2024
@qingzhoufeihu
Copy link
Author

Currently you can only avoid it by changing the revalidateOn option of useForm or createForm to 'submit'. What is your use case? Can't you enter a valid value when calling insert?

Thanks for your reply, "blur" works for me.I mean, if I set revalidateOn: "change" and then I click the "add new" button without entering anything in the newly appeared field, why does the new field directly trigger validation and show an error message?

@fabian-hiller
Copy link
Owner

This should only happen after the form has already been submitted, but I can see where you are coming from and why the current behavior can be annoying. Perhaps we should offer an option to control this when calling insert.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants