Field name with object path
See original GitHub issueIs it possible to achieve sth like this currently?
<Formik
initialValues={{ nested: { value: 'nested value' } }}
validationSchema={schema}
onSubmit={(values, { setSubmitting }) => {
handleSubmit(values);
setSubmitting(false);
}}
>
{() => (
<Form>
<Field name="nested.value" />
<button type="submit">Save</button>
</Form>
)}
</Formik>
I know I could use mapPropsToValues and mapValuesToPayload, but I find it really verbose and inconvenient for such a simple and common case. If I had deeply nested object, it would be even worse.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Using field path names to retrieve field values - IBM
A field path name provides the path to a named Entity. You can use GetLocalFieldPathNames for a given record type and then use...
Read more >Js or ES6 Get object field by path string when field has 2 or ...
fieldName "] you are checking if project has a key literally called "one.two.fieldName" including the dots. You can just split on dot and...
Read more >GridViewTextBoxColumn FieldName - path to referenced object
I am trying to bind a property of one class with the fieldName property. I have this class: Public Class Test.
Read more >Create or Edit key fields using Sales Path in Lightning
Lead and Opportunity object can have Key fields. ... Click New Path or Edit next to existing Path Name to customize 3. Click...
Read more >Java Reflection Field Value Set setFieldValueWithPath(Object ...
Returns the value of a field identified using a path from the parent. License. Apache License. Parameter. Parameter, Description. object, Parent object. path...
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 Free
Top 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

I tried to solve it in my custom component:
Please notice that I used
_.getinvalueprop so reading is working for nested values. The problem is, thatsetFieldValue('nested.value', value)would addnested.valuekey tovaluesobject, instead of adjustingvalues.nested.value. The same problem I would have forsetFieldError,setFieldTouchedetc.It seems that this library requires objects to be totally flat, but nested JSONs are really common. And flattening and “deflattening” in every form really kills productivity.
First of all - thanks for your hard work!
@jaredpalmer Would be great to add also nested
touchedanderrorsproposal prototype. Because now I’m usinggetfrom lodash for them like below:Where
field.namecorresponds to the nested object (eg.'address.city')