{%- set static = (static is defined ? static : false) %} {%- set cols = (cols is defined ? cols : []) %} {%- set rows = (rows is defined ? rows : []) -%} {% for col in cols %} {% endfor %} {% if not static %} {% endif %} {% 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 %} {% if not static %} {% endif %} {% endfor %}
{{ col.heading ? col.heading : ' ' }}
{%- if col.type == 'select' -%} {% include "_includes/forms/select" with { class: 'small', name: cellName, options: col.options, value: value, disabled: static } only %} {%- elseif col.type == 'checkbox' -%} {%- else -%} {%- endif -%}
{% if not static %}
{{ addRowLabel is defined ? addRowLabel : "Add a row"|t }}
{% endif %} {% if not static and (initJs is not defined or initJs) %} {% includejs %} new Craft.EditableTable( "{{ id | namespaceInputId | e('js') }}", "{{ name | namespaceInputName | e('js') }}", {{ cols|json_encode|raw }}); {% endincludejs %} {% endif %}