CMS Development

asa_curry
Member

passing an array into hubl choice field

I am trying to build a choice field into a module that will let a user select a row from a hubdb table to pass into the module via a choice field. I have successfully built the loop to create the array, but the choice field rejects the input and I can't determine why. 

 

{% set table = hubdb_table_rows( XXXXXX ) %}

{% set sections = [] %}

{% for row in table %}
{{ sections.append(row.content_id) }}
{% endfor %}

0 Upvotes
2 Replies 2
asa_curry
Member

passing an array into hubl choice field

I'm sorry, that code was incomplete, the following is returning an invalid argument error: 

 

% set sections = [] %}

{% for row in table %}
{{ sections.append(row.content_id) }}
{% endfor %}

{% choice "sections_field" label="How many sections?", value="default", choices="{{ sections }}", export_to_template_context=True %}

0 Upvotes
TRooInbound
Key Advisor

passing an array into hubl choice field

Hi @asa_curry,

 

I think there is issue with type of variable used for choices,  Instead of array use string variable and append string in it. and after that assign to choices attribute.

 

TRooInbound Team!

0 Upvotes