SOLVED

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Go to solution
Anonymous
Not applicable

Forms 2.0 loads without formid and munckinId populated, get an error on submit

Using forms 2.0 and loading multiple forms on some of the pages.  Sometimes one of the forms loads and it doesn't have formid and munchkinId populated. Has anyone seen this?

It does not happen 100% of the time.  Tried different computers, browsers, incognito windows etc, sometimes the fields are populated, sometimes they are not.

Have a temporary workaround where I just swing back with some javascript to populate these fields but this should not be happening.

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Have you looked into this code in is-mkto.min.js​?

var blockedForms = ["mktoForm_1688", "mktoForm_1182"]; 
for (var a = 0, i = blockedForms.length; i > a; a++)           
  $("#" + blockedForms[a] + " input").val("")

This code specifically clears fields, including hidden fields, and does not appear to be using the Marketo Forms 2.0 event model (i.e. it may have a race condition). One of those two forms (1182) is on your page.

View solution in original post

10 REPLIES 10
Grant_Booth
Level 10

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Hi Charles,

Are you doing this on Marketo hosted landing pages or non-Marketo pages? Since Marketo forms interact in a special way with Marketo pages, last I knew it wasn't supported to use multiple marketo forms on the same marketo page by using the embed code in an HTML block or hard-coding it into the template. That may have changed, but I know it used to run into problems.


Grant

Anonymous
Not applicable

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Doing this on our site.  We have a footer form that is on every page. So some form pages end up with 2 forms on the page. 

Not using embed code or hardcoding the forms, but using the 2.0 code, the form that is rendered is drawn directly from Marketo.

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Please provide a URL where you can -- at least after a human-capable number of tries -- reproduce this. I haven't dealt with this but It's easy to imagine a situation in which it could happen if you're talking about the same form ID on multiple times on the same page.

AFAIK the formid is actually read from the form descriptor, while the munchkinId is taken directly from the argument to loadForm.  Also note the Forms 2.0 library has been at the same rev for 2 weeks.

Anonymous
Not applicable

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Hi Sanford,

I have a url, but I have my workaround is running on it so you will not be able to see the behavior. https://www.infusionsoft.com/refer

Can't duplicate this in isolated instances, where I put two forms on a page and that's it, no extra scripts or mumbo jumbo, just the 2 forms. 

Note that It could be one of our scripts that is actually removing the values, but nothing we wrote is targeting those fields.

The forms load async so I can't put dom or javascript breakpoints in to see what's really happening.

Was wondering if anyone ran across it to more narrow down the issue, is it multi Marketo 2.0 forms or conflicting scripts on our end?

Thanks

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

I have a url, but I have my workaround is running on it so you will not be able to see the behavior. https://www.infusionsoft.com/refer

Can you please put up a repro URL so I can help you?

The forms load async so I can't put dom or javascript breakpoints in to see what's really happening.

Sure y'can. I do it all the time.

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Have you looked into this code in is-mkto.min.js​?

var blockedForms = ["mktoForm_1688", "mktoForm_1182"]; 
for (var a = 0, i = blockedForms.length; i > a; a++)           
  $("#" + blockedForms[a] + " input").val("")

This code specifically clears fields, including hidden fields, and does not appear to be using the Marketo Forms 2.0 event model (i.e. it may have a race condition). One of those two forms (1182) is on your page.

Anonymous
Not applicable

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Sanford, you've done it again! 

That's gotta be the problem.  Those are the 2 forms that were having issues.

We auto fill the forms and that script is meant to keep the auto fill from filling in the fields since we don't want the customer's info on them.  I don't think whomever wrote that piece thought about the hidden inputs being erased.

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

Happy to help.  That code should be wrapped in

     MktoForms2.whenReady(function(form){ ... })

because otherwise (even if you exclude the hidden fields) the run order isn't guaranteed.

Grant_Booth
Level 10

Re: Forms 2.0 loads without formid and munckinId populated, get an error on submit

You can disable prefill on specific fields in the form editor. There's no need to do that with custom code.
PrefillDisabled.png