Skip to content

Error with validation when registering array field and array item fields together #482

Description

@lexanth

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

When registering a field for both the array as a whole and individual array items, with array validation and item validation, final-form can throw an error.
Pretty niche use case to want fields for both the array as a whole and individual array items.

https://codesandbox.io/s/react-final-form-field-arrays-forked-vjf4lg?file=/index.js
Click one entry in the multi select - Cannot set a numeric property on an object

The error comes from using final-form-arrays, but is thrown from final-form.

What is the expected behavior?

Setting no exception (setIn is setting undefined`) should not blow up here

Sandbox Link

What's your environment?

Final-form 4.12.0
final-form-arrays 1.1.2
react-final-form 4.1.0
react-final-form-arrays 2.0.3

Other information

This is from not setting the ARRAY_ERROR quite as final-form wants it, but requiring that is hard to interop with e.g. yup. Mainly reporting this issue to record the error case, rather than because I expect a fix.

Another workaround is not to register fields for array items where not required - when using FieldArray like this, can use field.values to get the value, which is sufficient if we're just trying to read the value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions