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

Add index to FormDataConsumer when used inside an ArrayInput #10498

Open
dalen opened this issue Feb 6, 2025 · 1 comment
Open

Add index to FormDataConsumer when used inside an ArrayInput #10498

dalen opened this issue Feb 6, 2025 · 1 comment

Comments

@dalen
Copy link

dalen commented Feb 6, 2025

Is your feature request related to a problem? Please describe.

When writing some types of field level validators for fields inside an ArrayInput it would be useful to be able to get the index of the current component in some way. But I can also imagine other use cases for it.

Describe the solution you'd like

FormDataConsumer exposes formData & scopedFormData. I would like it to also expose index

Describe alternatives you've considered

Additional context

@djhi
Copy link
Collaborator

djhi commented Feb 11, 2025

This is not properly documented but there is a useSimpleFormIteratorItem hook that returns the index as you can see in the <SimpleFormIterator> documentation.

However, this implies to create a component which FormDataConsumer was actually meant to avoid. Can you open a PR for this targeting the next branch?

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

No branches or pull requests

2 participants