Form - Export to Template

benji_thecroc
Contributor | Gold Partner

Hi,

 

I have a form module declared with the export_to_template attribute like so -

 

 

{% form "event_signup" form_to_use='', title='Event Signup', export_to_template_context=True %}

 

 

Then within the template I try to have it functioning like so -

 

{% if widget_data.event_signup.form_id %}
<div class="event-signup">
  {% form
  	form_to_use="{{ widget_data.event_signup.form_id }}"
  	response_response_type="{{ widget_data.event_signup.response_type }}"
  	response_message="{{ widget_data.event_signup.message }}"
  	response_redirect_id="{{ widget_data.event_signup.redirect_id }}"
  	response_redirect_url="{{widget_data.event_signup.redirect_url}}"
  	gotowebinar_webinar_key="{{ widget_data.event_signup.gotowebinar_webinar_key }}"
  %}
</div>
{% endif %}

Usually with text I would output it like this -

 

{% if widget_data.event_date.value %}
<div class="content-meta">
  <p>{{ widget_data.event_date.value }}</p>
</div>
{% endif %}

However for the form I'm unsure of the syntax as well as the parameter needed for the if condition.

 

Any help is welcome.

 

Thanks,

Benji

0 Upvotes
1 Reply 1
lscanlan
HubSpot Alumni

Hi Benji @benji_thecroc,

 

For pulling values like that, I'd recommend two things. First, you can leverage the Developer Info tab, which is documented here: https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cms-pages. So from that Develoepr Info tab for your page, you could find the widget_data dict and see what's being outputted to the page. Then you'd locate your event_signup module and see what the values are there.

 

Another thing that's helpful is you can use the |pprint filter, which is documented here: https://designers.hubspot.com/docs/hubl/hubl-supported-filters#pprint. So often what I'll do is pretty print a module's data in the HTML like so:

 

<p>widget_data.event_signup|pprint: {{ widget_data.event_signup|pprint }}</p>

That helps me to see where to access module values. So all the parameters you need to access should be visible there. Let me know if this helps? I'm happy to look closer is this isn't detailed enough.

 

Leland Scanlan

HubSpot Developer Support
0 Upvotes