Hubl Server

Highlighted
Regular Contributor

I have set up a local Hubl Server + FTP and have just downloaded my files from Hubspot.

 

I have fired up the local server under localhost and erverything works correctly except it does not render the forms. (The form just renders a blank spot). Other modules seem to work correctly just not the forms.

Reply
0 Upvotes
3 Replies 3
Highlighted
HubSpot Alumni

Hi @SAU,

 

I just spun up a local HubL server as well and I'm actually seeing the default forms render. Could you let me know where they're not rendering? Is it in specific files? At least one example would be helpful so I can take a look and see if there's something we need to correct on our side. Did you modify the default files at all and then the forms aren't rendering?

 

Thanks for reporting this and let me know if you have other questions about local HubL in the meantime.

 

 - Leland

Leland Scanlan

HubSpot Developer Support
Highlighted
Regular Contributor

Only this renders a form and form_to_use does not work. There is nowhere to put your portalID anywhere? As soon as I put form_to_use it does not work. Do youur froms need to be stored somewhere? would the portal ID retreive them?

 

{% form "form" title='Free trial' %}
Reply
0 Upvotes
Highlighted
HubSpot Alumni

Hi @SAU, I think those forms that load through the local HubL server are meant as examples to give you an idea of what a form would look like on your page while you're developing locally. It's similar to the response I gave here regarding file manager paths: https://community.hubspot.com/t5/CMS-Development/PROBLEM-file-manager-cdn-HTML-images/m-p/253135#M11.... I don't think it's actually possible to pull a live form from an account through the form tag this way.

 

For loading a form locally, what about using the embed code from the form? Or you could set up a macro for the form embed code, where you'd only need to pass in the form ID as an argument. So that could look something like this:

 

{% macro form_embed(form_id) %}
    <!--[if lte IE 8]>
    <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
    <![endif]-->
    <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"></script>
    <script>
        hbspt.forms.create({
        portalId: "437004",
        formId: "{{ form_id }}"
    });
    </script>
{% endmacro %}

{{ form_embed('e528df01-96c4-42f9-ab9f-e263af6247f6') }}

 

That's assuming you're loading all forms from the same account. But you could add a parameter for the account ID, and optionally also for an element target if you wanted.

 

Let me know if you have any questions about it.

 

 - Leland

Leland Scanlan

HubSpot Developer Support
Reply
0 Upvotes