We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Feb 7, 2019 2:43 PM
I am writing a simple module where the user selects a "type" of webinar. I need to return both the value and label from this element. I couldn't find any documentation on how to do that. Is it possible?
This returns the value:
{{ module.event_type }}
I tried this and a few other iterations to return the label with no luck.
{{ module.event_type.label }}
Here's the full module code if needed. I'm simply trying to output the label itself.
<div class="event_wrapper event_type_{{ module.event_type }}"> <div class="event_left"> <p class="event_type"> {# I'm using this instead of outputting the label for the time being, but I would like it to be more flexible #} {% if module.event_type == "live_event" %} Creating Mindful Leaders Certification Workshop Live Event {% elif module.event_type == 'webcast_series' %} Creating Mindful Leaders Certification Workshop Webcast Series {% else %} Building Employee Resilience Webcast {% endif %} </p> <h3 class="event_title"><a href="{{ module.event_link.href }}" class="event_title_link">{{ module.title }}</a></h3> <p class="event_date_time"><span class="event_date">{{ module.event_date|datetimeformat('%B %e, %Y') }}</span>{% if module.event_time %} | <span class="event_time">{{ module.event_time }}</span>{% endif %}</p> <div class="event_desc_wrapper {% if module.event_image.src %}has_img{% endif %}"> {% if module.event_image.src %} <div class="event_img_cont"> <img src="{{ module.event_image.src }}" alt="{{ module.event_image.alt }}" width="{{ module.event_image.width }}" height="{{ module.event_image.height }}"> </div> {% endif %} <div class="event_desc"> {{ module.event_description }} </div> </div> </div> <div class="event_right"> <a href="{{ module.event_link.href }}" class="event_btn">{{ module.button_text }}</a> </div> </div>
Feb 23, 2021 9:18 AM
Chiming in that this feature should absolutely be implemented. Not sure if this has changed. Like @redbranchmedia said, you will want to use the value (which is often catered by the developer to omit spaces, punctuation, etc to avoid errors) for logic/filtering purposes and using the label for front-end display. Any CMS should have this. That's why values and labels exist.
Feb 11, 2019 10:01 PM
@redbranchmedia , not sure if this is what you need. hope it helps. let me know if i missed the ask
https://codepen.io/billyoncetoldme/pen/rPvPNo
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
Feb 19, 2019 12:31 PM
Thanks for taking the time to answer, I appreciate it.
Unfortunately, that's not what I'm looking for.
Right now, I have the choice hubl module set up with the following labels and values.
Label = "Creating Mindful Leaders Certification Workshop Live Event"
Value = "live_event"
Label = "Creating Mindful Leaders Certification Workshop Webcast Series"
Value = "webcast_series"
Label = "Building Employee Resilience Webcast"
Value = "webcast"
On the page editor, the users see the Labels and they make the choice accordingly. In the Hubl code, I'm using an if statement like so to determine which option they've selected:
{% if module.event_type == "live_event" %}
What I would like to do is use Hubl to output the Label. So, if the module.event_type value is equal to "live_event", for example, the output will be the Label for that value. In this case "Creating Mindful Leaders Certification Workshop Live Event".
Hope that helps!
Feb 19, 2019 8:28 PM
@redbranchmedia, i apologize if this is a dumb question, but why not set them to the same?
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
Feb 20, 2019 9:50 AM
Not a dumb question at all. I have found that when a Value is set to a sentence-like structure with spaces, punctionation, etc. it can cause issues when running if statements. Also, I'd like to be able to tweak the label as needed without changing the value and all the if statements.
Feb 20, 2019 10:12 AM
Hi @redbranchmedia,
When looking through the developer info on a module like this, it looks like HS only provides the value. I would recommend posting this into the ideas forum for them to also pass over the field label as well into the developer info so this would be something you can grab.
Developer Info Information here:
https://designers.hubspot.com/docs/hubl/how-to-use-developer-info-on-cos-pages
Image showing the dev info that you can copy paste into your post on the ideas forum if you want.
Feb 20, 2019 10:24 AM
Appreciate it! Will do.