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

Allow native post and put and patch form submissions #57

Open
AdeAttwood opened this issue Dec 1, 2022 · 1 comment
Open

Allow native post and put and patch form submissions #57

AdeAttwood opened this issue Dec 1, 2022 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@AdeAttwood
Copy link
Owner

Problem to solve

There is no way to do a native post request to the server using the Form component. It would be cool to have all the state management and validation that comes with the Form with a native post at the end of it.

Proposal

Allow the onSubmit prop to take a string of 'post' | 'put' | 'patch' along with the callback function that you can pass in now. If a string is passed in, then the method attribute on the form will be populated.

Then when the form is submitted it will be validated and then only when valid the form will be submitted.

We should probably also add a new prop for the action that allows us to submit the form to a different URL

Links / References

@AdeAttwood AdeAttwood added the enhancement New feature or request label Dec 1, 2022
@AdeAttwood AdeAttwood added this to the 0.x milestone Dec 10, 2022
@AdeAttwood AdeAttwood modified the milestones: 0.x, Backlog Jan 9, 2023
@AdeAttwood
Copy link
Owner Author

There is currently a workaround by accessing the event.target from the onSubmit callback.

https://react-form-sandy.vercel.app/submit

const onSubmit = ({ event }) => {
  event.target.method = "POST";
  event.target.submit();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant