vendor/sonata-project/admin-bundle/src/Resources/views/CRUD/base_list_field.html.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of the Sonata package.
  3. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. <td class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}"{% if field_description.options.row_align is defined %} style="text-align:{{ field_description.options.row_align }}"{% endif %}>
  8.     {% set route = field_description.options.route.name|default(null) %}
  9.     {% if
  10.         field_description.options.identifier|default(false)
  11.         and route
  12.         and admin.hasRoute(route)
  13.         and admin.hasAccess(route, route in ['show', 'edit'] ? object : null)
  14.     %}
  15.         <a class="sonata-link-identifier" href="{{ admin.generateObjectUrl(route, object, field_description.options.route.parameters) }}">
  16.             {%- block field %}
  17.                 {% apply spaceless %}
  18.                 {% if field_description.options.collapse is defined %}
  19.                     {% set collapse = field_description.options.collapse %}
  20.                     <div class="sonata-readmore"
  21.                           data-readmore-height="{{ collapse.height|default(40) }}"
  22.                           data-readmore-more="{{ collapse.more|default('read_more')|trans({}, 'SonataAdminBundle') }}"
  23.                           data-readmore-less="{{ collapse.less|default('read_less')|trans({}, 'SonataAdminBundle') }}">{{ value }}</div>
  24.                 {% else %}
  25.                     {{ value }}
  26.                 {% endif %}
  27.                 {% endapply %}
  28.             {% endblock -%}
  29.         </a>
  30.     {% else %}
  31.         {% set isEditable = field_description.options.editable is defined and field_description.options.editable and admin.hasAccess('edit', object) %}
  32.         {% set xEditableType = field_description.type|sonata_xeditable_type %}
  33.         {% if isEditable and xEditableType %}
  34.             {% set url = path(
  35.                 'sonata_admin_set_object_field_value',
  36.                 admin.getPersistentParameters|default([])|merge({
  37.                     'context': 'list',
  38.                     'field': field_description.name,
  39.                     'objectId': admin.id(object),
  40.                     'code': admin.code(object)
  41.                 })
  42.             ) %}
  43.             {% if field_description.type == 'date' and value is not empty %}
  44.                 {% set data_value = value.format('Y-m-d') %}
  45.             {% elseif field_description.type == 'boolean' and value is empty %}
  46.                 {% set data_value = 0 %}
  47.             {% else %}
  48.                 {% set data_value = value %}
  49.             {% endif %}
  50.             <span {% block field_span_attributes %}class="x-editable"
  51.                   data-type="{{ xEditableType }}"
  52.                   data-value="{{ data_value }}"
  53.                   data-title="{{ field_description.label|trans({}, field_description.translationDomain) }}"
  54.                   data-pk="{{ admin.id(object) }}"
  55.                   data-url="{{ url }}" {% endblock %}>
  56.                 {{ block('field') }}
  57.             </span>
  58.         {% else %}
  59.             {{ block('field') }}
  60.         {% endif %}
  61.     {% endif %}
  62. </td>