{# 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 is defined and route and admin.hasRoute(route) and admin.hasAccess(route, route in ['show', 'edit'] ? object : null) %} {%- block field %} {% spaceless %} {% if field_description.options.collapse is defined %} {% set collapse = field_description.options.collapse %}
{{ value }}
{% else %} {{ value }} {% endif %} {% endspaceless %} {% endblock -%}
{% else %} {% set isEditable = field_description.options.editable is defined and field_description.options.editable and admin.hasAccess('edit', object) %} {% set xEditableType = field_description.type|sonata_xeditable_type %} {% if isEditable and xEditableType %} {% 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 == 'date' and value is not empty %} {% set data_value = value.format('Y-m-d') %} {% elseif field_description.type == 'boolean' and value is empty %} {% set data_value = 0 %} {% else %} {% set data_value = value %} {% endif %} {{ block('field') }} {% else %} {{ block('field') }} {% endif %} {% endif %}