I'm pretty new to Formik, but one of the things I loved about it right away was the ability to wrap existing form field components with a <Field> and then use value={field.value} on my field component's props.
My field components also display stylized errors if passed to the error prop. I first tried accessing the field's error value using field.error, but eventually realized I couldn't get the field's error value that way, and would need to use the form prop.
Unfortunately (and this may be a separate issue), using form.errors[field.name] did not work for me, but using the lodash-style getIn(form.errors, field.name) did work. I suspect this might be due to nested-arrays in my values/errors model, but I have not yet had time to prove this out.
So I'm suggesting that field should support field.error and field.touched as convenience handles over using form.errors or form.touched. Also be sure these accessors will work when there are nested arrays in the form model.
Example:
When:
field.name = parents[0].children[0].firstName,
and
field.value = form.values.parents[0].children[0].firstName
then:
field.error = form.errors.parents[0].children[0].firstName
and
field.touched = form.touched.parents[0].children[0].firstName
As a Formik beginner I think this would make things simpler for other beginners.
In Formik 2, a meta property is in discussion (it would be breaking). The other idea is to provide a getFieldMeta getter function.
Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.
I find this proposal quite convenient! Please don't cl贸set this issue Mr. Bot xD
This is a duplicate of the following:
https://github.com/jaredpalmer/formik/issues/343
https://github.com/jaredpalmer/formik/issues/828
https://github.com/jaredpalmer/formik/pull/579
Most helpful comment
In Formik 2, a
metaproperty is in discussion (it would be breaking). The other idea is to provide agetFieldMetagetter function.