<?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 Re: Pre-populating form fields with react in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/519612#M25898</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt;&amp;nbsp;I'm wondering how you're accessing the HubSpot form like this as the HubSpot form I'm trying to reach is in an iframe?&lt;/P&gt;</description>
    <pubDate>Tue, 02 Nov 2021 14:12:11 GMT</pubDate>
    <dc:creator>MSoftware</dc:creator>
    <dc:date>2021-11-02T14:12:11Z</dc:date>
    <item>
      <title>Pre-populating form fields with react</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/432067#M22758</link>
      <description>&lt;P&gt;I am trying to pre-populate some of the input fields in our form which is integrated with our react application.&lt;BR /&gt;&lt;BR /&gt;I came across this thread which uses jQuery:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.hubspot.com/t5/CMS-Development/Embedded-Form-Populating-form-fields/td-p/284953" target="_blank"&gt;https://community.hubspot.com/t5/CMS-Development/Embedded-Form-Populating-form-fields/td-p/284953&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I also read through the hubspot docs which only shows jQuery options for editing input fields:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options" target="_blank"&gt;https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I tried multiple solutions on there and unfortunately jQuery doesn't play well with React.&amp;nbsp; I even tried using this NPM package and tried editing via the onReady function as well as in the componentDidMount lifecycle method:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.npmjs.com/package/react-hubspot-form" target="_blank"&gt;https://www.npmjs.com/package/react-hubspot-form&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Any idea how to auto-populate form fields with vanilla Javascript, or in a way that works with react?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance,&lt;BR /&gt;&lt;BR /&gt;Michael&lt;/P&gt;</description>
      <pubDate>Tue, 27 Apr 2021 18:40:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/432067#M22758</guid>
      <dc:creator>MJohnston2</dc:creator>
      <dc:date>2021-04-27T18:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-populating form fields with react</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/432420#M22772</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/185763"&gt;@MJohnston2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good question!&amp;nbsp; Adding a couple people to this who might be able to help.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt; , &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/138846"&gt;@kierana&lt;/a&gt;!&amp;nbsp; Do either of you have a solution for this?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Apr 2021 16:37:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/432420#M22772</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-04-28T16:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-populating form fields with react</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/433078#M22810</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/185763"&gt;@MJohnston2&lt;/a&gt;&amp;nbsp;-&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the global javascript events to populate form fields&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;window.addEventListener("message", function(event){
  if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormReady') {
    var form = document.getElementById('form[data-form-id="' + event.data.id + '"]');
    form.querySelector('.company_name')[0].value = 'Google';
  }
});&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like that&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 10:49:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/433078#M22810</guid>
      <dc:creator>tjoyce</dc:creator>
      <dc:date>2021-04-30T10:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-populating form fields with react</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/519612#M25898</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt;&amp;nbsp;I'm wondering how you're accessing the HubSpot form like this as the HubSpot form I'm trying to reach is in an iframe?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 14:12:11 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/519612#M25898</guid>
      <dc:creator>MSoftware</dc:creator>
      <dc:date>2021-11-02T14:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Pre-populating form fields with react</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/817124#M34952</link>
      <description>&lt;P&gt;Because it's in an iframe I had to do this&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;window.addEventListener("message", function(event){&lt;BR /&gt;   if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === 'onFormReady') {&lt;BR /&gt;       var formDocument = document.getElementById('hs-form-iframe-0').contentDocument&lt;BR /&gt;formDocument.getElementById('email-' + event.data.id).value = 'example@email.com';&lt;BR /&gt;    }&lt;BR /&gt;});&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 08 Jul 2023 11:57:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Pre-populating-form-fields-with-react/m-p/817124#M34952</guid>
      <dc:creator>ishields2</dc:creator>
      <dc:date>2023-07-08T11:57:20Z</dc:date>
    </item>
  </channel>
</rss>

