{% extends 'forms/' ~ layout|default('field') ~ '.html.twig' %} {# If values contains a plain list of items, we need to reindex them. #} {% set value = not field.key and value is iterable and value|length ? value|values : value %} {% block field %} {% if field.is_current %} {# Editing field itself, no need to append field name #} {% set name = '' %}
{% set labels = {collapse: 'GANTRY5_PLATFORM_COLLAPSE'|trans, expand: 'GANTRY5_PLATFORM_EXPAND'|trans} %} {% for key, val in value %} {% set title = (field.value == field.key ? key : val[field.value]) %} {% set id = route ~ '.' ~ key ~ '.' ~ field.value %}

{{ title }}

{{ block('collection_fields') }}
{% endfor %}
{% else %} {% set can_reorder = field.reorder ?? true %} {% set can_remove = field.deletion ?? true %} {% set can_addnew = field.add_new ?? true %}
{% if overrideable and (field.overridable is not defined or field.overridable == true or has_value) and field.type != 'container.set' %} {% include 'forms/override.html.twig' with {'scope': scope, 'name': name, 'field': field} %} {% endif %} {% block contents %} {% set field_route = (route ~ '.' ~ (prefix ? prefix ~ '.') ~ name)|replace({'.': '/'}) %} {% block label %} {% if field.description %} {% set description = field.description|trans_key('GANTRY5_FORM_FIELD', scope, name, 'DESC') %} {{ field.label|trans_key('GANTRY5_FORM_FIELD', scope, name, 'LABEL') }} {% else %} {{ field.label|trans_key('GANTRY5_FORM_FIELD', scope, name, 'LABEL') }} {% endif %} {{ field.validate.required in ['on', 'true', 1] ? '*' }} {% endblock %}
{% block input -%}
    {%- if field.fields -%} {% for key, val in value %} {% if (field.ajax == true) %}
  • {% set itemValue = field.value == field.key ? key : val[field.value] %} {% if can_reorder %}{% endif %} {{ itemValue }} {% if can_remove %}{% endif %} {% if can_addnew %}{% endif %}
  • {% else %} {% block collection_fields %}
    {% for childName, child in field.fields %} {% set container = child.type starts with 'container.' %} {% if childName starts with '.' %} {% set childKey = childName|trim('.') %} {% set childValue = container ? val : nested(val, childKey) %} {% set childName = name ~ '.' ~ key ~ childName %} {% else %} {% set childKey = childName %} {% set childValue = container ? val : nested(data, scope ~ childKey) %} {% set childName = childName|replace({'*': key}) %} {% set childParent = (childName == childKey) ? '.' ~ key ~ '.' %} {% endif %} {% if childName not in skip and not child.skip and field.value != childKey %} {% if child.type == 'key' %} {% include 'forms/fields/key/key.html.twig' with {name: childName, field: child, value: key, current_value: null, default_value: null, parent: childParent} %} {% elseif child.type %} {% include ["forms/fields/" ~ child.type|replace({'.': '/'}) ~ ".html.twig", 'forms/fields/unknown/unknown.html.twig'] with {name: childName, field: child, value: null, current_value: childValue, default_value: null, parent_field: childParent} %} {% endif %} {% endif %} {% endfor %}
    {% endblock %} {% endif %} {% endfor %} {%- endif -%}
  • {% if can_reorder %}{% endif %} New item {% if can_remove %}{% endif %} {% if can_addnew %}{% endif %}
{% if can_addnew %}{% endif %}
{% endblock %}
{% endblock %}
{% endif %} {% endblock %}