Currently, Formik includes all values from the form state in the submission data. When we need internal values for form logic/state that shouldn't be submitted, we have to manually filter them out in the onSubmit handler:
<Formik
initialValues={{
email: '',
_timestamp: Date.now() // internal value we don't want submitted
}}
onSubmit={(values) => {
const submitData = Object.fromEntries(
Object.entries(values).filter(([key]) => !key.startsWith('_'))
);
// Have to manually filter before submitting
submitForm(submitData);
}}
>
Desired Behavior
Formik should automatically exclude designated private values from the submission data while keeping them in form state. Values prefixed with underscore would be treated as private:
Developers building complex forms needing internal state
Teams working on multi-step forms/wizards
Anyone tracking form metadata
TypeScript users wanting type safety for private values
Describe alternatives you've considered
Manual filtering in onSubmit - current approach
Custom Formik wrapper
External state management using useState or zustand
Additional context
This is a common pattern that many developers implement manually. Having it built into Formik would provide a standard, type-safe way to handle internal form state while reducing boilerplate code.
Feature request: Private Form Values
Current Behavior
Currently, Formik includes all values from the form state in the submission data. When we need internal values for form logic/state that shouldn't be submitted, we have to manually filter them out in the onSubmit handler:
Desired Behavior
Formik should automatically exclude designated private values from the submission data while keeping them in form state. Values prefixed with underscore would be treated as private:
Suggested Solution
Add a new configuration option to Formik for handling private values:
Who does this impact? Who is this for?
Describe alternatives you've considered
Additional context
This is a common pattern that many developers implement manually. Having it built into Formik would provide a standard, type-safe way to handle internal form state while reducing boilerplate code.