How to use action in onSubmit #2901
-
I have a form that I want to submit to ActiveCampaign. If I was just making a regular html site, this is how the form element would look: I am wondering, how can I recreate that functionality using react hook form? In other words, this is how my form looks right now:
I assume that somehow or other I need to place the action and method inside the Any suggestions? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
you can use fetch inside the onSubmit and do a post to your end point. |
Beta Was this translation helpful? Give feedback.
-
I ran into this issue as well trying to reach out to a SalesForce endpoint, and I had to use the native const Form = () => {
const formRef = useRef<HTMLFormElement>(null)
const { handleSubmit } = useForm()
const onSubmit = () => formRef.current?.submit()
return (
<form
ref={formRef}
onSubmit={handleSubmit(onSubmit)}
action="https://the-url-you-wanna-use.com"
method="POST">
...
</form>
)
} |
Beta Was this translation helpful? Give feedback.
you can use fetch inside the onSubmit and do a post to your end point.