Set a Property Based off of the page the form was Submitted
SOLVE
We are a a home builder who might have over 30 communties at one time. Rather then create a monsterous workflow, I would like to be able to have a script run that sets our "Interested Community" property based off of the page the form was submitted.
So I think what's happening here is that when you include the css option in your embed code, it's creating what we refer to as a "raw HTML form". In other words, the form renders as just HTML on your page as opposed to within an iframe. And it looks like your code works when the form is a raw HTML form but not when it's iframed in, because your callback function doesn't have access to the frame that the form is in. So you can grab the document's URL and split it, but you can't set your value inside the hidden form input in the iframe.
So I think you'll need to use a raw HTML form for this in order to get the community name into your form input, and then you'll need to use your own custom CSS to get everything styled correctly. There's an option to set the form as raw HTML in the Style & preview tab of the form editor, which you can see here: https://knowledge.hubspot.com/articles/kcs_article/forms/how-do-i-style-my-embedded-form.
And when you say the formatting looks broken, does it sound like the above? Where the default CSS is just getting removed? Or is there something else at play do you think? In testing on my end, it just looked like the default CSS was getting removed.
Set a Property Based off of the page the form was Submitted
SOLVE
Hi Leland -
I used the following Scripts below. However, they don't work when I remove the css: line. With the css line, it makes the formating of my forms look broke.
So I think what's happening here is that when you include the css option in your embed code, it's creating what we refer to as a "raw HTML form". In other words, the form renders as just HTML on your page as opposed to within an iframe. And it looks like your code works when the form is a raw HTML form but not when it's iframed in, because your callback function doesn't have access to the frame that the form is in. So you can grab the document's URL and split it, but you can't set your value inside the hidden form input in the iframe.
So I think you'll need to use a raw HTML form for this in order to get the community name into your form input, and then you'll need to use your own custom CSS to get everything styled correctly. There's an option to set the form as raw HTML in the Style & preview tab of the form editor, which you can see here: https://knowledge.hubspot.com/articles/kcs_article/forms/how-do-i-style-my-embedded-form.
And when you say the formatting looks broken, does it sound like the above? Where the default CSS is just getting removed? Or is there something else at play do you think? In testing on my end, it just looked like the default CSS was getting removed.