Formik: Dirty values in onSubmit

Created on 3 Dec 2017  路  4Comments  路  Source: formium/formik

Hello all!

I am looking into using Formik for my next project and was looking to see if there was any way to have the onSubmit function receive only the values that changed (the dirty values).

Am looking to have a form that will submit only the fields that the user changed (instead of submitting the whole form).

I've looked for a way to do this in the docs and have not found anything.

Any ideas on how it can be done?

Thanks!

Most helpful comment

Could you not just diff the initialValues against the values from onSubmit?

All 4 comments

You can probably combine values and touched fields.

Thought about that and gave it a shot but as per the docs, touched is not available in onSubmit.

Could you not just diff the initialValues against the values from onSubmit?

@ericchernuka Sometimes the answer is right in front of you. You're right, that's all I had to do.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings