-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add field.error
and field.touched
support to <Field>
#963
Comments
field.error
and field.touched
support to field
prop of `<Field>field.error
and field.touched
support to field
prop of <Field>
field.error
and field.touched
support to field
prop of <Field>
field.error
and field.touched
support to <Field>
In Formik 2, a |
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 |
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 usevalue={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 theform
prop.Unfortunately (and this may be a separate issue), using
form.errors[field.name]
did not work for me, but using the lodash-stylegetIn(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.Suggested Solution
So I'm suggesting that
field
should supportfield.error
andfield.touched
as convenience handles over usingform.errors
orform.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
Who does this impact? Who is this for?
As a Formik beginner I think this would make things simpler for other beginners.
The text was updated successfully, but these errors were encountered: