Skip to main content
Mar 11, 2015 11:25 PM UTC
Solved

Embedded Forms 2.0 Duplicating in Drupal

Has anyone run into the issue when embedding a form on Drupal7, that the form appears without the custom CSS, and it is duplicated on the page?  If so, what was the fix?

 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Mar 12, 2015 8:00 PM UTC
OK, found it after some hunting.

Your jQuery "mmenu" plug-in duplicates the Marketo form... if it runs after the Marketo Forms 2.0 has been rendered.

Solution: Render the Marketo form after the mmenu is finished.  Put the Marketo code at the end of this block:

$(document).ready(function() {
var $mmenu_right = $("#mmenu_right");
       
...

MktoForms2.loadForm("//app-sjn.marketo.com", "417-GUB-995", 1442, function(){
jQuery('form#mktoForm_1442').addClass('munchkin-processed');
});

}(jQuery))

Also make sure the Marketo <SCRIPT> tag is in your <HEAD>.

8 replies

SanfordWhiteman
User Group Leader
User Group Leader
Mar 11, 2015 11:43 PM UTC
Wow, pretty cool.  Kidding, but... I would assume the code is literally running twice and/or there are two identical container DIVs (which is actually not allowed in HTML standard but it may cause this kind of screwup).  What's the URL?
Translate
Mar 12, 2015 12:17 AM UTC
Here is a sample page: test-a10.gotpantheon.com/en/node/11
Translate
SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Mar 12, 2015 8:00 PM UTC
OK, found it after some hunting.

Your jQuery "mmenu" plug-in duplicates the Marketo form... if it runs after the Marketo Forms 2.0 has been rendered.

Solution: Render the Marketo form after the mmenu is finished.  Put the Marketo code at the end of this block:

$(document).ready(function() {
var $mmenu_right = $("#mmenu_right");
       
...

MktoForms2.loadForm("//app-sjn.marketo.com", "417-GUB-995", 1442, function(){
jQuery('form#mktoForm_1442').addClass('munchkin-processed');
});

}(jQuery))

Also make sure the Marketo <SCRIPT> tag is in your <HEAD>.
Translate
Level 1
Apr 16, 2020 12:17 AM UTC

@sanfordwhiteman Thanks for sharing this!

Curious, is this still working for you. Not sure if anything has changed since 2015, but our developer didn't find this solution to work in Drupal today. Do you have any other suggestions or ideas of what we can try to resolve to the duplication of forms in Drupal?

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Apr 16, 2020 12:28 AM UTC

You'd have to provide your page. And pls open another thread in Products, this is way too old.

Translate
Mar 18, 2015 8:10 PM UTC
This worked, thank you @Sanford!
Translate