Closed shubhamgupta731 closed 4 years ago
I think we need to prevent the default behavior of the submission event. Dont see that happening anywhere in the source code.
@shubhamgupta731 Yes, you are right that default behavior should be prevented and it is mentioned in the docs. It was left out to user land for 2 reasons:
Since #1
can be addressed with introduction of target
s, it's possible to change this behavior unless #2
stands true for most of the users.
Sure, I understand. But can we update form
to Form
so that it becomes clear for anyone that we are talking about a custom component and provide a hyperlink to the form component that you use in your examples?
Yeah, we should address it one way or another. I'm not sure which way though :)
Lemme articulate the options:
Handle preventDefault
on submit in form.submit
handler when target
is ReactDom
.
<form onSubmit={event => form.submit(event)} />
Pros: users don't need to think about it. Cons:
form
tag for whatever reasonKeep it in user land and elaborate more in the docs. Pros: no changes needed except small changes to docs. Cons: possible confusion.
I have created the following form component:
However, when we submit the form (using the submit button), the form is getting submitted even when the validation for the field returns an error. However, I am able to correct the behavior if I change the
onSubmit
in the form to:Is there a mistake in the way I am using the ppx?