Sometimes, a customer might have data being loaded programmatically into a page and want that data to write to form fields. Because HubSpot Forms are generated programmatically with React, there need to be two considerations in your code that make setting fields programmatically more difficult:
- The data must be inserted after the form has finished loading
- Data that is inserted programmatically must have a js "change" event fired on the field in order to propagate the change into the React data layer
These two considerations are handled separately.
There are two methods to handle this - one including jQuery and one using vanilla javascript