Scrubbing invalid enums from formdata #2809
travisdahl
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Let me see if I can explain this.... When building schemas dynamically, specifically enum lists, the formData sometimes gets in a state where you have loaded new enums for that select but the stored value you have is no longer a valid enum. It would be nice if there was an option to automatically omit/reset that data to a default (which may have also changed based on the dynamic building of options).
So on change, if my value for an enum is not one of the allowed enums, set it to ...
(in this order)
A. a default if provided
B. The first valid enum
C. if A or B aren't applicable, an empty value
I have tried many things to get around this issue to no avail. Maybe this should be included in
omitExtraData
? Or a new option all together?UPDATE: kinda got it working by adding the following useEffect to my
SelectWidget
. There must be other useEffects running elsewhere as I can't get it to work right without thesetTimeout
(gross, I know).Beta Was this translation helpful? Give feedback.
All reactions