No way to access errors for a group defined with `withFieldGroup` #1652
Describe the bug#
When defining a group using withFieldGroup, it would be helpful to get a list of all of the errors for the group.
As an example, I have an address group. I'd like to render a list of errors at the group level (as opposed to the individual field level:
However, the group store only contains values. You can get the form-level errorMap and sort of work backwards, but that's somewhat difficult. It would be really nice if the group store had an errorMap or something similar.
Your minimal, reproducible example#
https://bolt.new/~/sb1-ehaxlmcw
Steps to reproduce#
Here is an example of the kind of form I mean.
Expected behavior#
It should be possible to get the errors for a group.
How often does this bug happen?#
None
Screenshots or Videos#
No response
Platform#
macOS/Chrome
TanStack Form adapter#
None
TanStack Form version#
1.15.1
TypeScript version#
No response
Additional context#
No response
LeCarbonator(GitHub profile, opens in a new tab) added labelstype: enhancement
Just to add to this my use case is for a field group looking like this
and I want my errors to show like the below instead of under the field and wrapping
An additional request here, accessing form meta in the field group. My specific use case is showing additional address fields like line 2 etc. only if line 1 is touched.
I second this requests, got into simmilar case and there is no way to get the errors back when they should group.getFieldMeta is getting fired but the errors are not passed into it until next rerender
Would love to see this as well.
Hi @LeCarbonator. I asked about this feature on Discord back in September last year and you kindly provided a link to this issue and said it was planned. Thanks for that.
I was just wondering how things are looking now. Can we expect to see this being implemented in the near future?
@andycochrane We're currently in the process of both
- Determining how to tackle this with the v1 architecture
- and how to improve functionality like this for v2
The major issue is that the v1 architecture really isn't built around this kind of hierarchal access, and changing that would require breaking changes. Therefore, we have to tinker with a solution that doesn't ruin performance.
There's a good chance this will be available in v1, and I can confirm that we're tracking v2 plans with this feature in mind.
That's good to know. I'll keep an eye out, thanks!
LeCarbonator(GitHub profile, opens in a new tab) added labelsv1
LeCarbonator(GitHub profile, opens in a new tab) added labelsv2
Sign in to join this conversation.
It wasn't initially part of the PR since field groups are supposed to link fields and forms together, not store (too much) state itself.
However, I see the use cases for including it!