Hi All
I would like to know if there are any guides and or suggestions to prepopulate a mautic form which is embedded on a website.
I have seen numerous ways to do this, including php, javascript etc
@joeyk Thanks. main issue is that its not working
I was hoping we could add a variable to a url where the form resides and the data would be pre-filled. But this is not the case.
Any other suggestions?
M
@adiux@rcheesley
I think perhaps this was not explained correctly. Our requirement was to use a variable from the CMS we are using to populate into the form. we have used PHP code to do this, grabbing the variable from the URL.
I was hoping that these could be achieved by default onto the form form, but sadly not.
Anyway our approach works, as long as we do not use the JavaScript integration.
Hi,
Just tested, and it works in 4.0.1, I didn’t test correctly before my answer above.
You have to make sure, that this setting is on in your form field, that you want to pre-populate:
var hashParams = window.location.hash.substr(1).split('&'); // substr(1) to remove the `#`
for(var i = 0; i < hashParams.length; i++){
var p = hashParams[i].split('=');
document.getElementById(p[0]).value = decodeURIComponent(p[1]);;
}