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 is_editable = field_description.options.editable is defined and field_description.options.editable and admin.hasAccess('edit', object) %}
  32.         {% if is_editable and field_description.options.multiple is defined and field_description.options.multiple and value is iterable %}
  33.             {# multiple editable field should be real multiple #}
  34.             {# https://vitalets.github.io/x-editable/docs.html#checklist #}
  35.             {% set x_editable_type = 'checklist' %}
  36.         {% else %}
  37.             {% set x_editable_type = field_description.type|sonata_xeditable_type %}
  38.         {% endif %}
  39.         {% if is_editable and x_editable_type %}
  40.             {% set url = path(
  41.                 'sonata_admin_set_object_field_value',
  42.                 admin.getPersistentParameters|default([])|merge({
  43.                     'context': 'list',
  44.                     'field': field_description.name,
  45.                     'objectId': admin.id(object),
  46.                     'code': admin.code(object)
  47.                 })
  48.             ) %}
  49.             {% if field_description.type == 'date' and value is not empty %}
  50.                 {% set data_value = value.format('Y-m-d') %}
  51.             {% elseif field_description.type == 'boolean' and value is empty %}
  52.                 {% set data_value = 0 %}
  53.             {% elseif value is iterable %}
  54.                 {% set data_value = value|json_encode %}
  55.             {% else %}
  56.                 {% set data_value = value %}
  57.             {% endif %}
  58.             <span {% block field_span_attributes %}class="x-editable"
  59.                   data-type="{{ x_editable_type }}"
  60.                   data-value="{{ data_value }}"
  61.                   {% if field_description.label is not same as(false) %}
  62.                     data-title="{{ field_description.label|trans({}, field_description.translationDomain) }}"
  63.                   {% endif %}
  64.                   data-pk="{{ admin.id(object) }}"
  65.                   data-url="{{ url }}" {% endblock %}>
  66.                 {{ block('field') }}
  67.             </span>
  68.         {% else %}
  69.             {{ block('field') }}
  70.         {% endif %}
  71.     {% endif %}
  72. </td>