<commit_before>{% set subject = metadata.name|replace({'_attribute': ''}) %}
{% for attributeId, localeCodes in forms %}
    {% for localeCode, form in localeCodes %}
        <div class="attribute" data-id="{{ attributeId }}">
            {% set id = form.vars.label|replace(' ', '_')|lower %}
            {% if 'type_checkbox' in form.vars.cache_key %}
                {{ _self.checkboxField(form, count, id, subject, metadata.applicationName) }}
            {% else %}
                {{ _self.textField(form, count, id, subject, metadata.applicationName) }}
            {% endif %}
            <input type="hidden"
                   name="sylius_product[attributes][{{ count }}][attribute]"
                   id="sylius_product_attributes_{{ count }}_attribute"
                   value="{{ attributeId }}"/>
            <input type="hidden"
                   name="sylius_product[attributes][{{ count }}][localeCode]"
                   id="sylius_product_attributes_{{ count }}_localeCode"
                   value="{{ localeCode }}"/>
            {% set count = count + 1 %}
        </div>
    {% endfor %}
{% endfor %}

{% macro formField(item, count, id, prefix, subject, applicationName) %}
    {% if item.children|length > 0 %}
        {% set prefix = prefix~'_'~item.vars.name %}
        {% for child in item.children %}
            {{ _self.formField(child, count, id, prefix) }}
        {% endfor %}
    {% elseif item.vars.name != '_token' %}
        {% set namePrefix = prefix|replace({'_': ']['}) %}
        {% set dataName = applicationName~'_'~subject~'[attributes]['~count~namePrefix~']['~item.vars.name~']' %}
        {% if item.vars.multiple %}
            {% set dataName = dataName~'[]' %}
        {% endif %}

        {{ form_widget(item, {'id': id, 'attr': {'data-name': dataName }}) }}
    {% endif %}
{% endmacro %}

{% macro textField(form, count, id, subject, applicationName) %}
    <div class="ui right fluid labeled input" style="margin-top: 15px; margin-bottom: 15px;">
        <div class="ui label">{{ form.vars.label }}</div>
        {{ _self.formField(form, count, id, '', subject, applicationName) }}
        <button class="ui red right labeled icon button">
            <i class="remove icon"></i> {{ 'sylius.ui.delete'|trans }}
        </button>
    </div>
{% endmacro %}

{% macro checkboxField(form, count, id, subject, applicationName) %}
    <div class="ui toggle checkbox" style="margin-top: 15px; margin-bottom: 15px;">
        {{ _self.formField(form, count, id, '', subject, applicationName) }}<commit_msg>[Attribute] fix undefined attribute in twig template<commit_after>{% set subject = metadata.name|replace({'_attribute': ''}) %}
{% for attributeId, localeCodes in forms %}
    {% for localeCode, form in localeCodes %}
        <div class="attribute" data-id="{{ attributeId }}">
            {% set id = form.vars.label|replace(' ', '_')|lower %}
            {% if 'type_checkbox' in form.vars.cache_key %}
                {{ _self.checkboxField(form, count, id, subject, metadata.applicationName) }}
            {% else %}
                {{ _self.textField(form, count, id, subject, metadata.applicationName) }}
            {% endif %}
            <input type="hidden"
                   name="sylius_product[attributes][{{ count }}][attribute]"
                   id="sylius_product_attributes_{{ count }}_attribute"
                   value="{{ attributeId }}"/>
            <input type="hidden"
                   name="sylius_product[attributes][{{ count }}][localeCode]"
                   id="sylius_product_attributes_{{ count }}_localeCode"
                   value="{{ localeCode }}"/>
            {% set count = count + 1 %}
        </div>
    {% endfor %}
{% endfor %}

{% macro formField(item, count, id, prefix, subject, applicationName) %}
    {% if item.children|length > 0 %}
        {% set prefix = prefix~'_'~item.vars.name %}
        {% for child in item.children %}
            {{ _self.formField(child, count, id, prefix) }}
        {% endfor %}
    {% elseif item.vars.name != '_token' %}
        {% set namePrefix = prefix|replace({'_': ']['}) %}
        {% set dataName = applicationName~'_'~subject~'[attributes]['~count~namePrefix~']['~item.vars.name~']' %}
        {% if item.vars.multiple is defined and item.vars.multiple %}
            {% set dataName = dataName~'[]' %}
        {% endif %}

        {{ form_widget(item, {'id': id, 'attr': {'data-name': dataName }}) }}
    {% endif %}
{% endmacro %}

{% macro textField(form, count, id, subject, applicationName) %}
    <div class="ui right fluid labeled input" style="margin-top: 15px; margin-bottom: 15px;">
        <div class="ui label">{{ form.vars.label }}</div>
        {{ _self.formField(form, count, id, '', subject, applicationName) }}
        <button class="ui red right labeled icon button">
            <i class="remove icon"></i> {{ 'sylius.ui.delete'|trans }}
        </button>
    </div>
{% endmacro %}

{% macro checkboxField(form, count, id, subject, applicationName) %}
    <div class="ui toggle checkbox" style="margin-top: 15px; margin-bottom: 15px;">
        {{ _self.formField(form, count, id, '', subject, applicationName) }}
{'fraction_non_alphanumeric': 0.17704918032786884, 'fraction_numerical': 0.003857280617164899, 'mean_word_length': 2.603891591382905, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '684258', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1444, 'n_words': 348}