{% extends 'forms/' ~ layout|default('field') ~ '.html.twig' %}

{% block contents %}
    <h5>{{ field.label }}</h5>
    <div>
    {% if field.fields %}
        {% for childName, child in field.fields %}
            {% if childName starts with '.' %}
                {% set childValue = value[childName[1:]] %}
                {% set childDefault = default_value[childName[1:]] %}
                {% set childName = name ~ childName %}
            {% else %}
                {% set childValue = nested(data, scope ~ childName) %}
                {% set childDefault = nested(defaults, scope ~ childName) %}
            {% endif %}

            {% if child.type %}
                {% include ["forms/fields/" ~ child.type|replace('.', '/') ~ ".html.twig", 'forms/fields/unknown/unknown.html.twig']
                with {name: childName, field: child, value: childValue, default_value: childDefault} %}
            {% endif %}
        {% endfor %}
    {% endif %}
    </div>
{% endblock %}
