Javascript in a form for UploadCare
Hello,
I’d like to use the tool named UploadCare to allow visitors to upload documents in a Marketo embedded form.
Regarding our specific configuration with our website, we use a CMS component to integrate Marketo form and there is a call to Marketo form to display it. To use UploadCare, I have to insert the javascript code directly in the form.
I read that I can add the code in the editor of the form as a HTML rich-text element, I copied the code provided by UploadCare Support with my API key (below).
<div>
<script>
UPLOADCARE_PUBLIC_KEY = "my_Key"; UPLOADCARE_PREVIEW_STEP = true;
</script>
</div>
<div>
<script src="https://ucarecdn.com/libs/widget/3.x/uploadcare.full.min.js"></script>
</div>
<div><input type="hidden" role="uploadcare-uploader" data-multiple="true" data-multiple-min="1" data-crop="4:3" name="upload-file" /></div>
The UploadCare widget is displayed but twice! (see attached the preview).

Despite the help of UploadCare Support, I wasn’t able to fix it.
Is this code correct?
Is it related to this post from @sanfordwhiteman ? https://nation.marketo.com/t5/Product-Blogs/HOWTO-Add-Forms-2-0-JS-behaviors-inside-a-Rich-Text-Area/ba-p/242768
I tried to insert this code as a HTML rich-text element but same behavior, the widget is displayed twice:
[Form Behaviors JS - Do Not Delete!]
<script>
MktoForms2.whenReady(function(form){
var formEl = form.getFormElem()[0];
if( formEl.getAttribute("data-inline-behaviors-loaded") == "true" ) {
return;
}
formEl.setAttribute("data-inline-behaviors-loaded", "true");
// now continue
console.log("Doing something special");
});
</script>
Any idea to fix it (note: I have no skill in development)?
Thank you!
BR,
Vincent