I'm using the code below to display the options within a multi-select hubdb table; if I only want to show the options for rows of a certain type, how would I do that?
Use case: on a page called Loss Prevention Forms, I only want to show rows that have form_type='loss prevention'. To take that one step further, I also want to show row.category in a sidebar filter (but only for the forms matching the previously stated criteria). I believe I'm close, but my code is not returning anything. See below. Thank you.
{% set table_info = hubdb_table_rows('2664478') %}
{% if row.form_type in table_info is containing 'Loss Prevention' %} {% for choice in hubdb_table_column(2664478, 4).options %} <div class="checkbox"> <input type="checkbox" value=".{{ choice.name|replace(' ','-')|lower }}"> <label class="checkbox-label">{{ choice.name }}</label> </div> {% endfor %}
The most inportant part will be the '.options'. For more info about it. Check HubDB column attributes:
{% set types = hubdb_table_column({Insert YOUR Table ID}, "type").options %}
{% for choice in types %}
{% set type_list = type_list~choice.id|list%}
{% if choice.id == request.query_dict.type%}
<option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
{% else %}
<option value="{{ choice.id }}">{{ choice.name }}</option>
{% endif %}
{% endfor %}
By default Checkboxes aren't supported by the HubDB filter, but there is a workaround that has been solved at the following topic. So I would recommend to check that out.