{# 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. #} {% set route = field_description.options.route.name|default(null) %} {% if field_description.options.identifier|default(false) and route and admin.hasRoute(route) and admin.hasAccess(route, route in ['show', 'edit'] ? object : null) %} {%- block field %} {% apply spaceless %} {% if field_description.options.collapse is defined %} {% set collapse = field_description.options.collapse %}
{{ value }}
{% else %} {{ value }} {% endif %} {% endapply %} {% endblock -%}
{% else %} {% set is_editable = field_description.options.editable is defined and field_description.options.editable and admin.hasAccess('edit', object) %} {% if is_editable and field_description.options.multiple is defined and field_description.options.multiple and value is iterable %} {# multiple editable field should be real multiple #} {# https://vitalets.github.io/x-editable/docs.html#checklist #} {% set x_editable_type = 'checklist' %} {% else %} {% set x_editable_type = field_description.type|sonata_xeditable_type %} {% endif %} {% if is_editable and x_editable_type %} {% set url = path( 'sonata_admin_set_object_field_value', admin.getPersistentParameters|default([])|merge({ 'context': 'list', 'field': field_description.name, 'objectId': admin.id(object), 'code': admin.code(object) }) ) %} {% if field_description.type == constant('Sonata\\AdminBundle\\Templating\\TemplateRegistry::TYPE_DATE') and value is not empty %} {% set data_value = value.format('Y-m-d') %} {% elseif field_description.type == constant('Sonata\\AdminBundle\\Templating\\TemplateRegistry::TYPE_BOOLEAN') and value is empty %} {% set data_value = 0 %} {% elseif value is iterable %} {% set data_value = value|json_encode %} {% else %} {% set data_value = value %} {% endif %} {{ block('field') }} {% else %} {{ block('field') }} {% endif %} {% endif %}