How to Customize the form embed code script.

Here is the example for to customize the “Form” Embed code script.

Updated script in view file

 getContext: function getContext() {
            //@class JJ.GetInTouch.getIntouch.View.Context
            const script = document.createElement("script");
            script.setAttribute("type", "text/javascript");
            script.src = "https://js.hsforms.net/forms/embed/v2.js";


            script.addEventListener("load", () => {
                hbspt.forms.create({
                    region: "na1",
                    portalId: "23130323",
                    formId: "22b95edc-a15c-4996-af4c-d32d6650a3a5",
                    target: "#myForumContainer",
                   
                });

            });
           
            document.head.prepend(script);

            return {}
        }

Updated .tpl file

<form id="Get-In-Touch">

    <body>
        <div class="container">
            <form action="/action_page.php">
                <div class="title_THR">
                    <h1 class="GetInTouch_Title">Get In Touch</h1>
                </div><br><br>
                <div class="Get_in_touch_mian_container">
                    <div id="myForumContainer"></div>
                </div>
            </form>

           
        </div>

    </body>
</form>



  

As per requirement we need to give styles.

Leave a comment

Your email address will not be published. Required fields are marked *