• Resolved Brandon C

    (@brandon-c)


    FYI,
    We are using a script to fill in some hidden fields on a WordPress site.
    We are also using shortcodes to embed the forms.
    This has been working fine for several years.
    We noticed that with the current version that the injected fields were no longer being saved and added to the contact in HS.

    We also noticed that if you left a mandatory field empty and clicked submit that we received an error in the browser console about the header size being too large. This is happening on both our live and localhost testing site.

    There were only 2 ways we found to resolve the problem.
    One was to manually add the embed code, not using the shortcode, and the other was to revert to an older plugin. In this case we reverted back to one that came out in March of this year.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support harthur90

    (@harthur90)

    Hi @brandon-c , thanks for your message

    Could you point me to the page/form you are having the issues?

    Best Regards

    Thread Starter Brandon C

    (@brandon-c)

    Unfortunately I can’t at this time. This are used on a couple of sites, on many forms, and a couple hundred submissions per day, so I had to revert to an older plugin version to remedy quickly.

    I can spin up a new Dev site if needed, but if you have a site I can test on by manually adding a script in the console and see if it has the same problem I would be glad to do so.

    Plugin Support harthur90

    (@harthur90)

    No problem at all

    Are you using elementor? We are currently investigating a issue with shortcodes + elementor.

    Also I am still able to get the form id if you provide me with the page so I can test it on my Dev site

    Best regards

    Thread Starter Brandon C

    (@brandon-c)

    We are using WPBakery not Elementor.
    I remembered I still have a Dev site with the new plugin installed that I didn’t delete yet, you can check on it but it is password protected.
    Is there a way to pass the info along to you that is private?

    Plugin Support harthur90

    (@harthur90)

    Hi @brandon-c, thanks for your message

    We don’t use users credentials to access their sites

    But if you could send your form id to [email protected] we can recreate it on our side

    Currently HubSpot is on its Week of rest, so there may be a delay

    Best regards

    Thread Starter Brandon C

    (@brandon-c)

    the site is password protected at the server level not at the WP level. The credentials are just so you can view.
    We have many forms that we use and it is the same deal with all of them.
    Need to use the latest plugin and create a script that enters the value in a hidden field and see if it is saved on Submit.

    I have tested it with all extra plugins deactivated, except for WP Bakery, and on a basic theme like 2020.

    Since this is an issue with the latest HubSpot shortcode only and we would also like to use the OnFormSubmit callback with it, which also doesn’t work – See https://community.hubspot.com/t5/APIs-Integrations/onFormSubmit-not-saving-value/td-p/653046 we are looking into creating our own shortcode, with OnformSubmit ability to circumvent these issues.

    Thread Starter Brandon C

    (@brandon-c)

    To help you determine if it’s a WPBakery issue I tested this on a fresh WP install, no extra plugins and 2020 theme.
    Still does the same thing. If you left a mandatory field empty and clicked submit we received an error in the browser console about the header size being too large and the injected fields were deleted.

    Thread Starter Brandon C

    (@brandon-c)

    An additional note to this.
    As it says in the first post we had to revert back to an older HubSpot plugin to get it working.
    Since the plugin versions, after the one we were forced to revert to, have some changes for security reasons, I would hope there was some priority attached to fixing this. Maybe you are working on it in the background but an update on progress would be nice.

    Plugin Support harthur90

    (@harthur90)

    Hi @brandon-c , Could you send me at least one form where you are facing this problem?

    I need this information to better understand the problem

    Best regards

    Plugin Support harthur90

    (@harthur90)

    @brandon-c do you need to have those hidden fields populated exactly at the submission event?

    I was able to populated/change an input at the OnFormReady event like this

    <script> window.addEventListener('message', event => {
    if (event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
    	var form = event.target.document.querySelector("#hs-form-iframe-0").contentDocument.querySelector(<code>#hsForm_${event.data.id}</code>);
    	var input = form.querySelector('input[name="firstname"]');
    	input.value = 'Fred' ;
    }}); </script>

    ;

    #hs-form-iframe-0 will be your first Form Iframe on the page, so if you have multiple forms you may need to change this

    Edit: In the above example you have access to the form element, so you should be able to attach an event handler for the submit event;

    Let me know if this helps

    • This reply was modified 2 years, 4 months ago by harthur90.
    • This reply was modified 2 years, 4 months ago by harthur90.
    • This reply was modified 2 years, 4 months ago by harthur90. Reason: typo
    • This reply was modified 2 years, 4 months ago by harthur90.
    Thread Starter Brandon C

    (@brandon-c)

    Hi harthur90,
    I sent you an email with info on how to test.
    The code above won’t work in our situation because we are not using the iframe. We are using it as raw html.

    Plugin Support harthur90

    (@harthur90)

    Hi,

    onFormSubmit is not supported for what you are trying to achieve, Here is how I got it working

     // This is an example - please update accordingly
    window.addEventListener("message", event => {
       if (event.data.type === "hsFormCallback"){
         switch(event.data.eventName){
           case "onFormReady":
           case "onFormFailedValidation":
               // If using Iframes
               var form = event.target.document.querySelector("#hs-form-iframe-0").contentDocument.querySelector('#hsForm_${event.data.id}');
               // If using raw html
                var form = event.target.document
                          .querySelector('#hsForm_${event.data.id}');
    
               // hidden field
               var input = form.querySelector("input[name='submission_date']");
               input.value = "06/28/2022";
               break;
           default:
              break;
         }
    

    Best regards

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Newer Plugin causing error when fields empty’ is closed to new replies.