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

Externally determining if form has errors #2343

Closed
1 task done
ronnyek opened this issue Apr 23, 2021 · 3 comments
Closed
1 task done

Externally determining if form has errors #2343

ronnyek opened this issue Apr 23, 2021 · 3 comments
Labels

Comments

@ronnyek
Copy link

ronnyek commented Apr 23, 2021

Prerequisites

Description

Honestly this is just quick question that I didn't find in searching first. Being that I'm not using submit button because of displaying a form in a dialog and wanting to use submit button of my modals, I'm curious what the best way to determine whether the form was in a "good" state... rather that validation is passing.

I know I can provide a onChange callback, and get at e.errors. Would the best way of providing the state to my modals button be to set a state variable isValid to e.errors.length> 0 and then use that as whether my button is enabled/disabled?

Is there a better way to get at that more directly? Appreciate any feedback.

@jacqueswho
Copy link
Contributor

should an easy change, if you want to make a PR, to include this functionality, please do. Possibly another callback called isValid could be added that we can called to check state of the form. regarding the submit button, I have a PR that will give more flexibility to hide the button. Read only forms will then be a possibility and change the text

@kfcaio
Copy link

kfcaio commented Mar 9, 2022

Are you able to get something like e.errors using React v17? I'm only getting undefined

onChange={
            (formData, e) => {
              console.log("Event:", e)
            }
          }

e is undefined

@heath-freenome
Copy link
Member

heath-freenome commented Sep 19, 2022

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

No branches or pull requests

4 participants