{%- set cols = (cols is defined ? cols : []) %} {%- set rows = (rows is defined ? rows : []) -%} {% for col in cols %} {% endfor %} {% for rowId, row in rows %} {% for colId, col in cols %} {% set cellName = name~'['~rowId~']['~colId~']' %} {% set value = (row[colId] is defined ? row[colId] : null) %} {% set textual = (col.type in ['singleline','multiline','number']) %} {% endfor %} {% endfor %}
{{ col.heading ? col.heading : ' ' }}
{%- if col.type == 'select' -%} {% include "_includes/forms/select" with { class: 'small', name: cellName, options: col.options, value: value } only %} {%- elseif col.type == 'checkbox' -%} {%- else -%} {%- endif -%}
{{ addRowLabel is defined ? addRowLabel : "Add a row"|t }}
{% if initJs is not defined or initJs %} {% set js %} new Craft.EditableTable( "{{ (jsId is defined ? jsId : id) | e('js') }}", "{{ (jsName is defined ? jsName : name) | e('js') }}", {{ cols|json_encode|raw }}); {% endset %} {% includeJs js %} {% endif %}