the Field parse prop function not called for initialValues
See original GitHub issueI use the parse prop to turn boolean values from a checkbox into numbers (1 or 0)
<Field type="checkbox" parse={ v => v ? 1 : 0 } format={ v => !! v } name="some-name" component="input" /> some-label
It works when I check a box, but if the checkbox gets checked automatically thanks to initialValues and then I submit the form without touching that checkbox then its value is a boolean (the parse function was not called).
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Updating initialValues prop on Formik Form does not update ...
The initialValues prop in both Form.js and FormikWithRef.js also reflect that value.input = 3000; However, the input does not update, using ...
Read more >Final Form Docs – `FieldProps`
The initial value for the field. This value will be used to calculate dirty and pristine by comparing it to the current value...
Read more >Field - Redux Form
The function is given the fields current value, all other form values, the props passed to the form, and the name of field...
Read more >Tutorial - Formik
Before we start. Welcome to the Formik tutorial. This will teach you everything you need to know to build simple and complex forms...
Read more >React + Redux Form — Two ways to add initial values
We pass a prop called initialValues into the form instance component and the value is an object with the keys being the name...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is an example: https://codesandbox.io/s/j2oyp3NWP
Developers can avoid this problem passing the parsed value to initialValues but I wonder if it makes more sense if this is managed by redux-form.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.