{# This file is part of the Sonata package. (c) Thomas Rabaix For the full copyright and license information, please view the LICENSE file that was distributed with this source code. #} {%- apply spaceless %} {# NEXT_MAJOR: Remove this BC-layer #} {% if field_description is defined %} {% set choices = choices|default(field_description.option('choices')) %} {% set multiple = multiple|default(field_description.option('multiple', false)) %} {% set delimiter = delimiter|default(field_description.option('delimiter', ', ')) %} {% set translation_domain = translation_domain|default(field_description.option('catalogue')) %} {% set safe = safe|default(field_description.option('safe', false)) %} {% endif %} {% set choices = choices|default([]) %} {% if multiple|default(false) and value is iterable %} {% set result = '' %} {% for val in value %} {% if result is not empty %} {% set result = result ~ delimiter|default(', ') %} {% endif %} {% if choices[val] is defined %} {% set choice = choices[val] %} {% else %} {% set choice = val %} {% endif %} {% if translation_domain|default(null) is null %} {% set result = result ~ choice %} {% else %} {% set result = result ~ choice|trans({}, translation_domain) %} {% endif %} {% endfor %} {% set value = result %} {% elseif value in choices|keys %} {% if translation_domain|default(null) is null %} {% set value = choices[value] %} {% else %} {% set value = choices[value]|trans({}, translation_domain) %} {% endif %} {% endif %} {% if safe|default(false) %} {{ value|raw }} {% else %} {{ value }} {% endif %} {% endapply -%}