<commit_before>{% extends '@DarvinAdmin/layout.html.twig' %}

{% import _self as this %}

{% form_theme form _self %}

{% trans_default_domain 'admin' %}

{% macro config_link(type, current_type) %}
    {% set title = ('configuration.action.edit.heading.' ~ type)|trans %}

    {% if type == current_type %}
        <span>{{ title }}</span>
    {% else %}
        <a href="{{ path('darvin_admin_configuration', {'type': type}) }}">{{ title }}</a>
    {% endif %}
{% endmacro %}

{% macro form_row_start(row) %}

    {% set expanded_cookie = 'darvin_admin_config' %}
    {% set expanded        = row.vars.id in app.request.cookies.get(expanded_cookie)|split(',') %}

    <div class="main_options_item_container"{% if row.vars.hidden|default %} style="display: none;"{% endif %}>
        <div class="main_options_item{% if expanded %} is-open{% endif %}">
            <div class="heading">
                <div class="name">{{ form_label(row) }}</div>
                <div class="btn_toggle{% if expanded %} is-open{% endif %}"
                     data-text-open="{% trans %}configuration.action.edit.toggle.collapse{% endtrans %}"
                     data-text-close="{% trans %}configuration.action.edit.toggle.expand{% endtrans %}"
                     data-cookie="{{ expanded_cookie }}"
                     data-id="{{ row.vars.id }}">{{ ('configuration.action.edit.toggle.' ~ (expanded ? 'collapse' : 'expand'))|trans }}</div>
            </div>
            <div class="content"{% if expanded %} style="display: block;"{% endif %}>
{% endmacro %}

{% macro form_row_end() %}
            </div>
        </div>
    </div>
{% endmacro %}

{% macro form_row(row) %}

    {% import '@DarvinAdmin/configuration/edit.html.twig' as this %}

    {{ this.form_row_start(row) }}
    {% if row.children is not empty %}
        {% for child in row.children if
            child.vars.compound
            and 'hidden' != child.vars.block_prefixes[1]|default
            and ('collection' != child.vars.block_prefixes[1]|default or not child.vars.allow_add)
        %}
            {% if 'darvin_admin_translatable' == child.vars.block_prefixes[1]|default %}
                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                {{ form_row(child) }}
            {% else %}
                {{ this.form_row(child) }}
            {% endif %}
        {% endfor %}
    {% endif %}
    {% if not row.rendered %}
        <div class="content_type-table">
            {% for child in row %}
                {% if 'hidden' == child.vars.block_prefixes[1]|default %}
                    {{ form_widget(child) }}
                {% else %}
                    <div class="item">
                        {% if not child.vars.compound or ('collection' == child.vars.block_prefixes[1]|default and child.vars.allow_add) %}
                            <div class="name">{{ form_label(child) }}</div>
                        {% endif %}
                        <div class="val">

                            {% set attr = {} %}

                            {% if 'collection' == child.vars.block_prefixes[1]|default %}

                                {% set attr = attr|merge({
                                    'data-allow-add':    +child.vars.allow_add,
                                    'data-allow-delete': +child.vars.allow_delete,
                                    'data-name':         child.vars.name,
                                }) %}

                                {% if child.vars.allow_add %}

                                    {% set attr = attr|merge({'data-index': child.children is not empty ? max(child.children|keys) + 1 : 0}) %}

                                {% endif %}
                            {% endif %}
                            {% if 'darvin_admin_ace_editor' == child.vars.block_prefixes[3]|default %}
                                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                                {{ form_widget(child, {'attr': attr, 'style': {'position': 'relative'}}) }}
                            {% else %}

                                {% set attr = attr|merge({
                                    'class': child.vars.block_prefixes[1]|default,
                                }) %}

                                {% if 'collection' == attr.class %}

                                    {% set attr = attr|merge({'class': 'js-collection'}) %}

                                {% endif %}
<commit_msg>Fix collection initialization in configuration edit form.<commit_after>{% extends '@DarvinAdmin/layout.html.twig' %}

{% import _self as this %}

{% form_theme form _self %}

{% trans_default_domain 'admin' %}

{% macro config_link(type, current_type) %}
    {% set title = ('configuration.action.edit.heading.' ~ type)|trans %}

    {% if type == current_type %}
        <span>{{ title }}</span>
    {% else %}
        <a href="{{ path('darvin_admin_configuration', {'type': type}) }}">{{ title }}</a>
    {% endif %}
{% endmacro %}

{% macro form_row_start(row) %}

    {% set expanded_cookie = 'darvin_admin_config' %}
    {% set expanded        = row.vars.id in app.request.cookies.get(expanded_cookie)|split(',') %}

    <div class="main_options_item_container"{% if row.vars.hidden|default %} style="display: none;"{% endif %}>
        <div class="main_options_item{% if expanded %} is-open{% endif %}">
            <div class="heading">
                <div class="name">{{ form_label(row) }}</div>
                <div class="btn_toggle{% if expanded %} is-open{% endif %}"
                     data-text-open="{% trans %}configuration.action.edit.toggle.collapse{% endtrans %}"
                     data-text-close="{% trans %}configuration.action.edit.toggle.expand{% endtrans %}"
                     data-cookie="{{ expanded_cookie }}"
                     data-id="{{ row.vars.id }}">{{ ('configuration.action.edit.toggle.' ~ (expanded ? 'collapse' : 'expand'))|trans }}</div>
            </div>
            <div class="content"{% if expanded %} style="display: block;"{% endif %}>
{% endmacro %}

{% macro form_row_end() %}
            </div>
        </div>
    </div>
{% endmacro %}

{% macro form_row(row) %}

    {% import '@DarvinAdmin/configuration/edit.html.twig' as this %}

    {{ this.form_row_start(row) }}
    {% if row.children is not empty %}
        {% for child in row.children if
            child.vars.compound
            and 'hidden' != child.vars.block_prefixes[1]|default
            and ('collection' != child.vars.block_prefixes[1]|default or not child.vars.allow_add)
        %}
            {% if 'darvin_admin_translatable' == child.vars.block_prefixes[1]|default %}
                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                {{ form_row(child) }}
            {% else %}
                {{ this.form_row(child) }}
            {% endif %}
        {% endfor %}
    {% endif %}
    {% if not row.rendered %}
        <div class="content_type-table">
            {% for child in row %}
                {% if 'hidden' == child.vars.block_prefixes[1]|default %}
                    {{ form_widget(child) }}
                {% else %}
                    <div class="item">
                        {% if not child.vars.compound or ('collection' == child.vars.block_prefixes[1]|default and child.vars.allow_add) %}
                            <div class="name">{{ form_label(child) }}</div>
                        {% endif %}
                        <div class="val">

                            {% set attr = {} %}

                            {% if 'collection' == child.vars.block_prefixes[1]|default %}

                                {% set attr = attr|merge({
                                    'class':             'js-collection',
                                    'data-allow-add':    +child.vars.allow_add,
                                    'data-allow-delete': +child.vars.allow_delete,
                                    'data-name':         child.vars.name,
                                }) %}

                                {% if child.vars.allow_add %}

                                    {% set attr = attr|merge({'data-index': child.children is not empty ? max(child.children|keys) + 1 : 0}) %}

                                {% endif %}
                            {% endif %}
                            {% if 'darvin_admin_ace_editor' == child.vars.block_prefixes[3]|default %}
                                {% form_theme child '@DarvinAdmin/fields.html.twig' %}
                                {{ form_widget(child, {'attr': attr, 'style': {'position': 'relative'}}) }}
                            {% else %}

                                {% set attr = attr|merge({
                                    'class': (attr.class|default ~ ' ' ~ child.vars.block_prefixes[1]|default)|trim,
                                }) %}

{'fraction_non_alphanumeric': 0.15735641227380015, 'fraction_numerical': 0.0022479487467685737, 'mean_word_length': 1.5539609644087256, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4616517', 'n_tokens_mistral': 2681, 'n_tokens_neox': 2336, 'n_words': 453}