Open jhackett1 opened 4 years ago
The link for the sandbox seems wrong (Request failed with status code 404).
But something I noticed, it seems you have a typo in your field's name name="favoruite"
-> name="favourite"
.
Any chance the bug is related to that?
If it's not that, please update the link for the sandbox. Best.
Current Behavior
Summary: I have a form with a select input that has dynamic options. Formik doesn't seem to pick up the correct values.
I'm building a Formik form with two parts:
In the first part, the user provides an array of strings.
In the second, the user uses a select to choose one option, where the options are dynamically populated from the values given in the first half, like this
Since the user provides the values for this select as part of the form, I've set formik's initial value to an empty string.The select should default to the first value in the array of options.
Looking at the form on the screen, everything behaves and functions fine — I can see the select input "fill out" as I type values into the first part of the form, but when I inspect the array of values on submission it only contains the initial empty string, and my "myKey can't be blank" validation is firing on it.
I think I either need to somehow force formik to grab the value from the select input, either when i submit the form, or as the earlier inputs where the user is supplying the options for it are changed?
Code sandbox
Expected behavior
Formik's value object should correctly pick up the up-to-date value of the select, at minimum when i submit the form.
If this isn't a bug, some docs on how to handle the case of a select with dynamic options would be appreciated.
Your environment
Firefox, MacOS