Skip to content
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

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

Open
lexanth opened this issue Jun 30, 2023 · 1 comment

Comments

@lexanth
Copy link

lexanth commented Jun 30, 2023

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.

@gertdreyer
Copy link
Collaborator

See https://codesandbox.io/s/react-final-form-field-arrays-forked-mx8532?file=/index.js for getting ARRAY_ERROR set correctly on the object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants