You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
<FormikinitialValues={{email: '',_timestamp: Date.now()// internal value we don't want submitted}}onSubmit={(values)=>{constsubmitData=Object.fromEntries(Object.entries(values).filter(([key])=>!key.startsWith('_')));// Have to manually filter before submittingsubmitForm(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:
Add a new configuration option to Formik for handling private values:
// Option 1: Simple prefix-based approach<FormikprivateValuePrefix="_">
// Option 2: More flexible configuration
<FormikprivateValues={{prefix: '_',// exclude all values starting with _keys: ['specificKey'],// exclude specific keyspredicate: (key)=>key.startsWith('_')// custom logic}}>
Who does this impact? Who is this for?
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: