<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Submitting form via API creates new 'non-hubspot' form in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Submitting-form-via-API-creates-new-non-hubspot-form/m-p/860198#M67987</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using Next.js with react-hook-form to handle my forms. I managed to get everything up and running but... the form is getting submitted twice! The second submission seems to be caused by your hubspot tracking script that I have attached via GTM. When I turn it off, the submission happens only once and data is going to the correct form. Once I turn on that tracking script again the form is submitted second time and creates a new 'non hubspot form' and names it by my CSS classes (which to me, is extremely silly).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DMakos_0-1696517177224.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/100545i8CC79D83DF82561C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DMakos_0-1696517177224.png" alt="DMakos_0-1696517177224.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried inlcuding the usertoken cookie but it didn't have any effect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After submitting I get the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-10-05 at 15.47.35.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/100546i869B3FFD85EE4DB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-10-05 at 15.47.35.png" alt="Screenshot 2023-10-05 at 15.47.35.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above is correct, but after a moment the second request pops in:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DMakos_0-1696517406660.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/100548i0A50F30281C3035C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DMakos_0-1696517406660.png" alt="DMakos_0-1696517406660.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The page does not refresh after submission as obviously I'm using preventDefault() method on the event to stop the default form submission and handle it with my own JS.&lt;BR /&gt;&lt;BR /&gt;Why is this happening? How can I prevent it? I provided everything as requested in your docs including optional parameters but I just can't stop this second request from happening via your script...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to keep tracking users but still be able to use my custom form and just submit it thorugh the API endpoint...&lt;/P&gt;</description>
    <pubDate>Thu, 05 Oct 2023 14:55:52 GMT</pubDate>
    <dc:creator>DMakos</dc:creator>
    <dc:date>2023-10-05T14:55:52Z</dc:date>
    <item>
      <title>Submitting form via API creates new 'non-hubspot' form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Submitting-form-via-API-creates-new-non-hubspot-form/m-p/860198#M67987</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using Next.js with react-hook-form to handle my forms. I managed to get everything up and running but... the form is getting submitted twice! The second submission seems to be caused by your hubspot tracking script that I have attached via GTM. When I turn it off, the submission happens only once and data is going to the correct form. Once I turn on that tracking script again the form is submitted second time and creates a new 'non hubspot form' and names it by my CSS classes (which to me, is extremely silly).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DMakos_0-1696517177224.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/100545i8CC79D83DF82561C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DMakos_0-1696517177224.png" alt="DMakos_0-1696517177224.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried inlcuding the usertoken cookie but it didn't have any effect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After submitting I get the following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-10-05 at 15.47.35.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/100546i869B3FFD85EE4DB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-10-05 at 15.47.35.png" alt="Screenshot 2023-10-05 at 15.47.35.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above is correct, but after a moment the second request pops in:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DMakos_0-1696517406660.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/100548i0A50F30281C3035C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DMakos_0-1696517406660.png" alt="DMakos_0-1696517406660.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The page does not refresh after submission as obviously I'm using preventDefault() method on the event to stop the default form submission and handle it with my own JS.&lt;BR /&gt;&lt;BR /&gt;Why is this happening? How can I prevent it? I provided everything as requested in your docs including optional parameters but I just can't stop this second request from happening via your script...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to keep tracking users but still be able to use my custom form and just submit it thorugh the API endpoint...&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 14:55:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Submitting-form-via-API-creates-new-non-hubspot-form/m-p/860198#M67987</guid>
      <dc:creator>DMakos</dc:creator>
      <dc:date>2023-10-05T14:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: Submitting form via API creates new 'non-hubspot' form</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Submitting-form-via-API-creates-new-non-hubspot-form/m-p/860723#M68013</link>
      <description>&lt;P&gt;I solved it by doing this:&lt;/P&gt;&lt;P&gt;1. My submit button was changed to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;Button type="button" onClick={handleSubmit(onSubmit)} /&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. As I lost submit event by hitting enter on my form, I had to handle this as well for accessibility:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;form onKeyUp={(e) =&amp;gt; handleKeyUp(e)}&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    const handleKeyUp = (e) =&amp;gt; {
        if (e.key === 'Enter') {
            handleSubmit(onSubmit)(e);
        }
    };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. Finally just handle the submission&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    const onSubmit = async (data, e) =&amp;gt; {
        e.preventDefault();
        // do stuff...
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps someone with similar situation.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 09:48:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Submitting-form-via-API-creates-new-non-hubspot-form/m-p/860723#M68013</guid>
      <dc:creator>DMakos</dc:creator>
      <dc:date>2023-10-06T09:48:11Z</dc:date>
    </item>
  </channel>
</rss>

