question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FormItem errors aren't working for FieldArray's

See original GitHub issue

Using this example from Formik https://jaredpalmer.com/formik/docs/api/fieldarray

If we pass errors with the same way back as they are structured inside values.

e.g.: values:

{
  filters: [
    { name: undefined }
  ]
}

errors:

{
  filters: [
    { name: "Required!" }
  ]
}

FormItem doesn’t catch the error. Mostly like because it’s expecting a flat level key name.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
jannikbuschkecommented, Apr 5, 2019

You can clone this repository https://github.com/jannikbuschke/formik-antd-playground with the --recursive flag and have a good local test experience. Pls follow the README to get started (it should be very simple)

0reactions
jwmanncommented, Apr 8, 2019

For some reason, using formik-antd-playground. name always appears as "" which is really strange. Do you know why that could be?

the name inside the field object is also "" however props.name is actually the right name

I made a component on the app side minus the Form.Item part and it seems to be a Formik problem? Or maybe some kind of typescript issue that I’m not aware of. Basically, I can pass name to Field and Field’s props name remains ""

Seems as though the problem was in the original name variable after all. name was being passed but not destructured from props. I was confused because I’m not used to typescript so I assumed props: { name: string; children: React.ReactNode } & FormItemProps was destructuring it, but it wasn’t. So name was just an undeclared variable. No idea why that didn’t error on compile.


Also sidenote, the default version of formik-antd that formik-antd-playground installs is 0.8.2. I had to manually pull in the latest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ant design custom Form List: How to handle Array inside an ...
List whenever I have an array of objects but the above value is different, because it is array inside an array and then...
Read more >
DynamicForm (Smart GWT LGPL Edition API 13.0p (2022-12 ...
Returns whether there are currently any errors visible to the user for the specified field in this form, without performing any validation. void,...
Read more >
Date field doesn't allow attributes [#2854722] | Drupal.org
My custom form date field is set up as follows: And the error ... If "because array defaults aren't merged" is true we...
Read more >
Dynamic AngularJS Validation in ngRepeat - Mitch Valenta
You can do so by utilizing an array of, well, anything really. The reason being is that you aren't actually dependent on the...
Read more >
Updates - FormValidation
elements, HTMLElement[], The array of current field elements ... The Bulma plugin doesn't add the error styles to select elements ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found