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

Add global Formsy.isPristine() function #62

Open
eranshabi opened this issue Jan 21, 2018 · 4 comments
Open

Add global Formsy.isPristine() function #62

eranshabi opened this issue Jan 21, 2018 · 4 comments

Comments

@eranshabi
Copy link

eranshabi commented Jan 21, 2018

It would be really useful to be able to use isPristine in the component that has the <Formsy/>, for example for when you want to enable submit only when form is dirty. Right now we need to track the dirty state of the form ourselves. We have isPristine only inside the input component (with.Formsy).

Is this request align with Formsy intended design? Would a PR be welcome for this?

@rkuykendall rkuykendall changed the title Formsy (no withFormsy isPristine()) Add global Formsy.isPristine() function Feb 22, 2020
@rkuykendall
Copy link
Member

A pull request would be very welcome for this feature.

@hafnis
Copy link

hafnis commented Feb 28, 2020

Had the same question today and that value is kinda there. Formsy pass two properties to onChange callback - current form values and result of internal func isChanged, which actually does what we need - checks whether any input value has changed.
See https://github.com/formsy/formsy-react/blob/master/src/index.ts#L395

@rkuykendall
Copy link
Member

rkuykendall commented Feb 28, 2020

If we renamed isChanged to isPristine and added it to API.md does that solve this feature?

A test would be nice too, if it became a publically documented function.

@hafnis
Copy link

hafnis commented Feb 28, 2020

You should probably think about dynamically added/removed fields too. isChanged returns true if you add/remove fields dynamically, since default state for all new fields is pristine, though, is whole form still pristine? It's a philosophical question :)

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

No branches or pull requests

4 participants