Input field in embedded form doesn't send value

forms

#1

Hi, i have an email field in embedded form in my react component, everything look to be working but, when the user click submit the value of the field doesn’t send to Hubspot.

I fill the value in the email field automatically and i use JQuery change() as Hubspot suggest.
It seems to erase the value when the field is in focus and then in blur.
When i fill the email field manually it’s working and the value doesn’t erase.

here i implement Hubspot’s embedded form:
componentDidMount() {
const script = document.createElement(“script”);

    script.src = 'https://js.hsforms.net/forms/v2.js';
    document.body.appendChild(script);

    script.addEventListener('load', () => {
        if (window.hbspt) {
            window.hbspt.forms.create({
                portalId: '2529493',
                formId: 'd7e9455a-9293-4396-917c-0347994cbd47',
                target: '#hubspotForm'
            });
        }
    });

Here i input the email address to email field in the form:

 placeUserEmail = () => {
    const emailField = $("input[name='email']");
    let {email} = window.user;

    emailField.val(email).change();}

#2

Hi @jovstern,

Can you try putting the script that automatically populates the email field in the onFormReady callback function? I’m wondering if you’re updating the email field before the form is fully rendered.


#3

That’s exactly what i did and it works!
Tnx