# FORM in custom modules

**URL:** <https://community.hubspot.com/t/form-in-custom-modules/47570>\
**Category:** CMS Development\
**Tags:** professional\
**Created:** [November 25, 2021, 11:42am UTC](https://community.hubspot.com/t/form-in-custom-modules/47570 "2021-11-25T11:42:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichalC](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/michalc/32/62359_2.png) [@MichalC](https://community.hubspot.com/u/MichalC)\
**Post date:** [November 25, 2021, 11:42am UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/1 "2021-11-25T11:42:45Z")

</div>

Hello, is there any possibility that HS developers have changed something in the way of loading hs forms in custom modules? I have an issue while adding two same custom modules to one landing/website page. What I’ve noticed is that now hs form is loaded in container with ID “hs\_form\_target\_{{ module name }}”. So in case you are adding two same custom modules, you’ve got two same IDs on one page. And if I get it right, the form from the second module is loading in the first container and overrides the correct one while the second module is empty. Is there any way to avoid it?

M.

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [November 25, 2021, 12:22pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/2 "2021-11-25T12:22:49Z")

</div>

Hi @MichalC, how are you adding the form to your custom module?

My recommendation would be to add a form selector field in the custom module, then use this HubL where you want the form

```lia-code-sample
{% form
 form_to_use="{{ module.form.form_id }}"
 response_response_type="{{ module.form.response_type }}"
 response_message="{{ module.form.message }}"
 response_redirect_id="{{ module.form.redirect_id }}"
 response_redirect_url="{{ module.form.redirect_url }}"
%}

```

This will allow you to have the same module multiple times on one page and have different forms in each iteration/version of said module

---

<div class="post-metadata">

**Author:** ![MichalC](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/michalc/32/62359_2.png) [@MichalC](https://community.hubspot.com/u/MichalC)\
**Post date:** [November 25, 2021, 12:30pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/3 "2021-11-25T12:30:35Z")

</div>

Hello @piersg , thank you for quick reply. The problem is that it used to work all fine, and I am already using it that way :

 ![MichalC_0-1637843191036.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/4/458ffecbdab3eb8f24bfd4de29d0c6569bc37c30.png)

The problem is that if you will add two sam modules on one page, form from the second module is loading in the first one,

As I mentioned, I have added two modules and each of them has same conteiner ID (which is added automaticly) and I think that can cause the problem.

I have created simple page, try to hit refresh button while you visit this page, it will load different forms at each time  
here is a sample : [page](https://25115943.hs-sites-eu1.com/pageforivan)

---

<div class="post-metadata">

**Author:** ![Mariuszsz](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mariuszsz/32/197538_2.png) [@Mariuszsz](https://community.hubspot.com/u/Mariuszsz)\
**Post date:** [January 26, 2023, 12:10pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/4 "2023-01-26T12:10:02Z")

</div>

@piersg And how does your json file look like? Thanks!

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [January 26, 2023, 6:40pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/5 "2023-01-26T18:40:27Z")

</div>

It varies but usually like this

```lia-code-sample
{
 "id" : "[ID]",
 "name" : "form",
 "display_width" : null,
 "label" : "Form",
 "required" : false,
 "locked" : false,
 "type" : "form",
 "default" : {
 "response_type" : "inline",
 "message" : "Thanks for submitting the form."
 }
 }

```

There’s more info on form field JSON here: [Module and theme fields - HubSpot docs](https://developers.hubspot.com/docs/cms/building-blocks/module-theme-fields#form)

---

<div class="post-metadata">

**Author:** ![Mariuszsz](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mariuszsz/32/197538_2.png) [@Mariuszsz](https://community.hubspot.com/u/Mariuszsz)\
**Post date:** [January 26, 2023, 7:32pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/6 "2023-01-26T19:32:34Z")

</div>

Thanks a lot… you are right. I forgot about it. One more question. Do you think that the sent message could be editable outside the code?

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [January 27, 2023, 12:39pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/7 "2023-01-27T12:39:16Z")

</div>

Yeah, if you include a form field in a custom module it automatically includes a thank you message rich text field.

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [November 25, 2021, 1:42pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/8 "2021-11-25T13:42:44Z")

</div>

I think you just need to remove `form_key="{{ blockname }}"` . When I use the above code, Hubspot gives the wrapping div a unique id in each iteration of the module e.g. “hs\_form\_target\_form\_34625612” and “hs\_form\_target\_form\_127648987”, whereas yours is repeating “hs\_form\_target\_ctaDefault06”.

---

<div class="post-metadata">

**Author:** ![MichalC](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/michalc/32/62359_2.png) [@MichalC](https://community.hubspot.com/u/MichalC)\
**Post date:** [November 25, 2021, 1:49pm UTC](https://community.hubspot.com/t/form-in-custom-modules/47570/9 "2021-11-25T13:49:52Z")

</div>

@piersg thank you! that was the issue.
