<commit_before><div class="js-form-container">
    {% embed '@DarvinAdmin/content.html.twig' %}

        {% trans_default_domain 'admin' %}

        {% set heading = (meta.baseTranslationPrefix ~ 'action.edit.title')|trans({'%entity%': entity|trans}) %}

        {% block breadcrumbs %}{{ admin_breadcrumbs(meta, parent_entity, heading) }}{% endblock %}

        {% block heading %}{{ heading }}{% endblock %}

        {% block header_buttons %}
            {% if entity %}
                {{ admin_widget('actions', entity, {'view_type': 'edit', 'style': 'header'}) }}
            {% endif %}
            <a class="page-header__btn-save-add" href="">Сохранить и добавить ещё</a>
            <a class="page-header__btn-save-edit" href="">Сохранить и редактировать</a>
            <a class="page-header__btn-save" href="">Сохранить изменения</a>
        {% endblock %}

        {% block content %}{% include '@DarvinAdmin/crud/_form.html.twig' with {'view_type': 'edit'} %}{% endblock %}

        {% block footer %}
            <div class="page-footer">
                <div class="page-footer__btns">
                    {% if entity %}
                        {{ admin_widget('actions', entity, {'view_type': 'edit', 'style': 'footer'}) }}
                    {% endif %}
                    <a class="page-footer__btn-save-add" href="">Сохранить и добавить ещё</a>
                    <a class="page-footer__btn-save-edit" href="">Сохранить и редактировать</a>
                    <a class="page-footer__btn-save" href="">Сохранить изменения</a>
                </div>
            </div>
        {% endblock %}

    {% endembed %}
</div><commit_msg>Refactor CRUD edit template.<commit_after>{% import _self as that %}

{% trans_default_domain 'admin' %}

{% macro buttons(entity, form, style) %}

    {% set classes = {
        'submit_edit':  'page-' ~ style ~ '__btn-save-edit',
        'submit_index': 'page-' ~ style ~ '__btn-save',
        'submit_new':   'page-' ~ style ~ '__btn-save-add',
    } %}

    {% if entity %}
        {{ admin_widget('actions', entity, {'view_type': 'edit', 'style': style}) }}
    {% endif %}
    {% for name, row in form %}
        {% if 'submit' == row.vars.block_prefixes[1] %}
            <a class="{{ classes[name] }}"
               href="#"
               onclick="document.getElementById('{{ row.vars.id }}').click(); return false;">
                {{ row.vars.label|trans }}
            </a>
        {% endif %}
    {% endfor %}
{% endmacro %}

{% set header_buttons = that.buttons(entity, form, 'header') %}
{% set footer_buttons = that.buttons(entity, form, 'footer') %}

<div class="js-form-container">
    {% embed '@DarvinAdmin/content.html.twig' %}

        {% trans_default_domain 'admin' %}

        {% set heading = (meta.baseTranslationPrefix ~ 'action.edit.title')|trans({'%entity%': entity|trans}) %}

        {% block breadcrumbs %}{{ admin_breadcrumbs(meta, parent_entity, heading) }}{% endblock %}

        {% block heading %}{{ heading }}{% endblock %}

        {% block header_buttons %}{{ header_buttons }}{% endblock %}

        {% block content %}{% include '@DarvinAdmin/crud/_form.html.twig' with {'view_type': 'edit'} %}{% endblock %}

        {% block footer %}
            <div class="page-footer">
                <div class="page-footer__btns">
                    {{ footer_buttons }}
                </div>
            </div>
        {% endblock %}

    {% endembed %}
</div>
{'fraction_non_alphanumeric': 0.18313532309475514, 'fraction_numerical': 0.0002897710808461316, 'mean_word_length': 2.297039159503343, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '4134614', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1038, 'n_words': 204}