{{ hiddenInput(name, '') }}
{% 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}]" %} {% set blockAttributes = { class: [ 'matrixblock', not block.enabled ? 'disabled', static ? 'static', ]|filter, data: { id: blockId, type: block.getType().handle, collapsed: block.collapsed, }, } %}
{% if not static %} {{ hiddenInput("#{name}[sortOrder][]", blockId) }} {# only register a delta name for this black if it's not new #} {% if not blockIsNew %} {% do view.registerDeltaName(baseInputName) %} {% endif %} {{ hiddenInput("#{baseInputName}[type]", block.getType().handle) }} {{ hiddenInput("#{baseInputName}[enabled]", block.enabled ? '1' : '') }}
{{ block.getType().name|t('site') }} {% if block.hasErrors() %}{% endif %}
{% endif %}
{% include "_includes/fields" with { namespace: "#{baseInputName}[fields]", element: block, fields: block.getType().getFieldLayout().getFields(), static: static, registerDeltas: not blockIsNew, } %}
{% endfor %}
{% if not static and not staticBlocks %}
{% for blockType in blockTypes %}
{{ blockType.name|t('site') }}
{% endfor %}
{% endif %}