{%- set static = static ?? false %}
{%- set staticRows = static or (staticRows ?? false) %}
{%- set cols = cols ?? [] %}
{%- set rows = rows ?? [] %}
{%- set initJs = not static and (initJs ?? true) -%}
{% for col in cols %}
{%- if col.heading is defined and col.heading %}{{ col.heading }}{% else %} {% endif %}
{%- if col.info is defined -%}
{{ col.info|md|raw }}
{%- endif -%}
{% endfor %}
{% if not staticRows %}
{% endif %}
{% for rowId, row in rows %}
{% for colId, col in cols %}
{% set cell = row[colId] ?? null %}
{% set value = cell.value is defined ? cell.value : cell %}
{% if col.type == 'heading' %}
{{ value|raw }}
{% else %}
{% set hasErrors = cell.hasErrors ?? false %}
{% set cellName = name~'['~rowId~']['~colId~']' %}
{% set textual = (col.type in ['color', 'date', 'multiline', 'number', 'singleline', 'time']) %}
{% set isCode = col.code is defined or col.type == 'color' %}
{%- switch col.type -%}
{%- case 'checkbox' -%}
{% include "_includes/forms/checkbox" with {
name: cellName,
value: col.value ?? 1,
checked: value is not empty,
disabled: static
} only %}
{%- case 'color' -%}
{% include "_includes/forms/color" with {
name: cellName,
value: value,
small: true,
disabled: static
} only %}
{%- case 'date' -%}
{% include "_includes/forms/date" with {
name: cellName,
value: value,
disabled: static
} only %}
{%- case 'lightswitch' -%}
{% include "_includes/forms/lightswitch" with {
name: cellName,
on: value,
value: col.value ?? 1,
small: true,
disabled: static
} only %}
{% case 'select' -%}
{% include "_includes/forms/select" with {
class: 'small',
name: cellName,
options: cell.options ?? col.options,
value: value,
disabled: static
} only %}
{%- case 'time' -%}
{% include "_includes/forms/time" with {
name: cellName,
value: value,
disabled: static
} only %}
{%- default -%}
{%- endswitch -%}
{% endif %}
{% endfor %}
{% if not staticRows %}
{% endif %}
{% endfor %}
{% if not staticRows %}
{{ addRowLabel is defined ? addRowLabel : "Add a row"|t('app') }}