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

Manually submit form outside of <Form> component #42

Closed
TimMikeladze opened this issue Feb 27, 2017 · 5 comments
Closed

Manually submit form outside of <Form> component #42

TimMikeladze opened this issue Feb 27, 2017 · 5 comments

Comments

@TimMikeladze
Copy link

It would be useful to call the submit and validate methods of a form while in a different component outside of the

parent. Consider the scenario when you want to have your submit form button reside in a different component hierarchy then the form.

Maybe it's already possible to do this?

Please let me know what you think, thanks.

@tannerlinsley
Copy link
Collaborator

The easiest way to do this is to use a ref:

<ReactForm ref={el => this.form = el}>

// Somewhere else in the parent component
this.form.submitForm()

Does that work for you?

@TimMikeladze
Copy link
Author

Thank you for the response!

@z-vr
Copy link
Contributor

z-vr commented May 5, 2017

Thanks, wouldn't know what to do otherwise (partly because I've never used ref property in React). @tannerlinsley I think it would be worth adding to the documentation.

@tannerlinsley
Copy link
Collaborator

tannerlinsley commented May 5, 2017 via email

@z-vr
Copy link
Contributor

z-vr commented Jan 11, 2018

@tannerlinsley this has stopped working in v2, submitForm is not a function which I can access after creating a ref to the form, but getApi should be used instead.

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

3 participants