Browse Source

Restore old link

Thomas Rabaix 11 years ago
parent
commit
d9ab04897c
1 changed files with 12 additions and 2 deletions
  1. 12 2
      Resources/views/CRUD/base_list_field.html.twig

+ 12 - 2
Resources/views/CRUD/base_list_field.html.twig

@@ -16,10 +16,20 @@ file that was distributed with this source code.
         and admin.isGranted(field_description.options.route.name == 'show' ? 'VIEW' : field_description.options.route.name|upper, object)
         and admin.hasRoute(field_description.options.route.name)
     %}
-        <a class="identifier" href="{{ admin.generateObjectUrl(field_description.options.route.name, object, field_description.options.route.parameters) }}">
+        <a class="sonata-link-identifier" href="{{ admin.generateObjectUrl(field_description.options.route.name, object, field_description.options.route.parameters) }}">
             {%- block field %}{{ value }}{% endblock -%}
         </a>
     {% else %}
-        {{ block('field') }}
+        {% set isEditable = field_description.options.editable is defined and field_description.options.editable and admin.isGranted('EDIT', object) %}
+        {% set xEditableType = field_description.type|sonata_xeditable_type %}
+
+        {% if isEditable and xEditableType %}
+            {% set url = path('sonata_admin_set_object_field_value', { 'context': 'list', 'field': field_description.name, 'objectId': admin.id(object), 'code': admin.code(object) })  %}
+            <span {% block field_span_attributes %}class="x-editable" data-type="{{ xEditableType }}" data-value="{{ value }}" data-title="{{ field_description.label|trans({}, field_description.translationDomain) }}" data-pk="{{ admin.id(object) }}" data-url="{{ url }}" {% endblock %}>
+                {{ block('field') }}
+            </span>
+        {% else %}
+            {{ block('field') }}
+        {% endif %}
     {% endif %}
 </td>