Passing section context data to nested group in custom module
SOLVE
I have created a section with context and am trying to pass data to the custom module, but cannot figure out the Hubl to access grouped fields. Example outlined below, where there is a repeater group inside my custom module and I want to pass a unique image field or link to display in the template. For the section heading I can use a string easily, but I cannot figure out the groups.
Sep 2, 202211:44 AM - edited Sep 2, 202211:45 AM
HubSpot Employee
Passing section context data to nested group in custom module
SOLVE
The only way I was able to get this to work was to apply attributes at the top level. Therefore, the value of card_content must be a json string with the values needed. So in your example something like this should work:
{# Basic Example #}
{% module_attribute 'group_name' %}
{ field_name: 'field value' }
{% end_module_attribute %}
{# Your use case #}
{% module_attribute 'card_content' %}
{ image_field: {{ context.image || get_asset_url('../images/blank-page-banner.png') }} }
{% end_module_attribute %}
I got this working in my test using the first code example above. I'm not 100% sure of what HubL is acceptable inside dnd areas or module_attribute areas. I feel like dot notation should work like you tried, but I couldn't get it to work witout just assigning the parent group a json value.