Sfoglia il codice sorgente

Possibility to choose list identifier route

Emmanuel Vella 13 anni fa
parent
commit
b02636d590

+ 4 - 0
Datagrid/ListMapper.php

@@ -39,6 +39,10 @@ class ListMapper
     {
         $fieldDescriptionOptions['identifier'] = true;
 
+        if (!isset($fieldDescriptionOptions['route'])) {
+            $fieldDescriptionOptions['route'] = 'edit';
+        }
+
         return $this->add($name, $type, $fieldDescriptionOptions);
     }
 

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

@@ -12,7 +12,7 @@ file that was distributed with this source code.
 <td class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}">
     {% if field_description.options.identifier is defined and admin.isGranted(['EDIT', 'SHOW']) %}
 
-        {% if admin.hasroute('edit') and admin.isGranted('EDIT') %}
+        {% if field_description.options.route == 'edit' and admin.hasroute('edit') and admin.isGranted('EDIT') %}
             <a href="{{ admin.generateObjectUrl('edit', object) }}">
         {% elseif admin.hasroute('show') %}
             <a href="{{ admin.generateObjectUrl('show', object) }}">
@@ -24,4 +24,4 @@ file that was distributed with this source code.
     {% else %}
         {{ block('field') }}
     {% endif %}
-</td>
+</td>