turner-industries / formik-semantic-ui

https://www.npmjs.com/package/formik-semantic-ui
53 stars 18 forks source link

Can't access errors for nested properties #10

Closed bcornett closed 5 years ago

bcornett commented 5 years ago

Using an object that has nested properties:

{
    name: '',
    physicalAddress: {
        addressLine1: '',
        addressLine2: '',
        city: '',
        state: '',
        zip: '',
    }
}

And an component like:

<Input label="Address 1" name="physicalAddress.addressLine1" />

My errors won't show up for any physicalAddress item. I believe this is because of the way you're trying to access the errors in the helper.js on line 7 - form.errors[name].

These may be helpful: https://github.com/jaredpalmer/formik/issues/413 http://blog.nicohaemhouts.com/2015/08/03/accessing-nested-javascript-objects-with-string-key/

bcornett commented 5 years ago

Using something like I mentioned in the 2nd link worked: getNested(form.errors, name)

justinobney commented 5 years ago

closed in #13