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

Question : Parent component to access children form state #4184

Closed
raphaelnoguier opened this issue Mar 10, 2023 · 2 comments
Closed

Question : Parent component to access children form state #4184

raphaelnoguier opened this issue Mar 10, 2023 · 2 comments
Labels
✨ enhancement a "nice to have" feature

Comments

@raphaelnoguier
Copy link

Hello @logaretm !

Thanks for this amazing package. I've just upgraded to v4 and i have this use case

<parent-component>
  <child-form-1 />
  <child-form-2 />
  ...
</parent-component>

How can my parent-component get access to all errors and the validate function of each child form ?

I have a global submit button on my parent component and i want this button to trigger validation inside each children component.

Is there anything to solve that kind of scenario ?

(I've seen an another issue mentionning inject(FormContextKey) but I couldn't get it to work...

Thanks again :)

@logaretm logaretm added the ✨ enhancement a "nice to have" feature label Apr 4, 2023
@logaretm
Copy link
Owner

logaretm commented Apr 4, 2023

Hey, so inject(FormContextKey) works for the other way around. You getting the parent state in a child.

So far there isn't a way to do the opposite, but I'm having second thoughts about this limitation. For now, you can try looking for aggregating form state issues/examples because it is similar to this one.

@raphaelnoguier
Copy link
Author

Thanks for the response, i'll try that !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement a "nice to have" feature
Projects
None yet
Development

No branches or pull requests

2 participants