{#

This file is part of the Sonata package.

(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% extends get_admin_template('base_list_field', admin.code) %}

{% set is_editable =
    field_description.option('editable', false) and
    admin.hasAccess('edit', object)
%}
{% set x_editable_type = field_description.type|sonata_xeditable_type %}

{% block field_span_attributes %}
    {% if is_editable and x_editable_type %}
        {% apply spaceless %}
            {{ parent() }}
            data-source="{{ field_description|sonata_xeditable_choices|json_encode }}"
        {% endapply %}
    {% endif %}
{% endblock %}

{# NEXT_MAJOR: Remove the fallback on catalogue #}
{% block field %}
    {%- include '@SonataAdmin/CRUD/display_choice.html.twig' with {
        value: value,
        choices: field_description.option('choices'),
        multiple: field_description.option('multiple'),
        delimiter: field_description.option('delimiter'),
        translation_domain: field_description.option('choice_translation_domain', field_description.option('catalogue')),
        safe: field_description.option('safe'),
    } only -%}
{% endblock %}
