{% set totalNewBlocks = 0 %} {% for block in blocks %} {% set blockId = block.id %} {% set blockIsNew = blockId is empty %} {% if blockIsNew %} {% set totalNewBlocks = totalNewBlocks + 1 %} {% set blockId = 'new' ~ totalNewBlocks %} {% endif %} {% set baseInputName = "#{name}[blocks][#{blockId}]" %} {# only register a delta name for this black if it's not new #} {% if not blockIsNew %} {% do view.registerDeltaName(baseInputName) %} {% endif %}
{{ hiddenInput("#{name}[sortOrder][]", blockId) }} {{ hiddenInput("#{baseInputName}[type]", block.getType().id) }}
{% include "super-table/row/fields" with { namespace: "#{baseInputName}[fields]", element: block, fields: block.getType().getFieldLayout().getFields(), settings: supertableField, registerDeltas: not blockIsNew, } %}
{% if not staticField %}
{% endif %}
{% endfor %}
{% if not staticField %}
{{ supertableField.selectionLabel | default("Add a row") | t('site') }}
{% endif %}