Quellcode durchsuchen

Fix error if no "batch" route is available

Andrej Hudec vor 12 Jahren
Ursprung
Commit
6b000b7cd2
1 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen
  1. 6 2
      Resources/views/CRUD/base_list.html.twig

+ 6 - 2
Resources/views/CRUD/base_list.html.twig

@@ -22,13 +22,15 @@ file that was distributed with this source code.
 {% block list_table %}
 {% block list_table %}
     {% set batchactions = admin.batchactions %}
     {% set batchactions = admin.batchactions %}
     {% if admin.datagrid.results|length > 0 %}
     {% if admin.datagrid.results|length > 0 %}
+        {% if admin.hasRoute('batch') %}
         <form action="{{ admin.generateUrl('batch', {'filter': admin.filterParameters}) }}" method="POST" >
         <form action="{{ admin.generateUrl('batch', {'filter': admin.filterParameters}) }}" method="POST" >
+        {% endif %}
             <table class="table table-bordered table-striped">
             <table class="table table-bordered table-striped">
                 {% block table_header %}
                 {% block table_header %}
                     <thead>
                     <thead>
                         <tr class="sonata-ba-list-field-header">
                         <tr class="sonata-ba-list-field-header">
                             {% for field_description in admin.list.elements %}
                             {% for field_description in admin.list.elements %}
-                                {% if field_description.getOption('code') == '_batch' and batchactions|length > 0%}
+                                {% if admin.hasRoute('batch') and field_description.getOption('code') == '_batch' and batchactions|length > 0 %}
                                     <th class="sonata-ba-list-field-header sonata-ba-list-field-header-batch">
                                     <th class="sonata-ba-list-field-header sonata-ba-list-field-header-batch">
                                       <input type="checkbox" id="list_batch_checkbox" />
                                       <input type="checkbox" id="list_batch_checkbox" />
                                     </th>
                                     </th>
@@ -74,7 +76,7 @@ file that was distributed with this source code.
                         <th colspan="{{ admin.list.elements|length - (app.request.isXmlHttpRequest ? (admin.list.has('_action') + admin.list.has('batch')) : 0) }}">
                         <th colspan="{{ admin.list.elements|length - (app.request.isXmlHttpRequest ? (admin.list.has('_action') + admin.list.has('batch')) : 0) }}">
                             <div class="form-inline">
                             <div class="form-inline">
                                 {% if not app.request.isXmlHttpRequest %}
                                 {% if not app.request.isXmlHttpRequest %}
-                                    {% if batchactions|length > 0  %}
+                                    {% if admin.hasRoute('batch') and batchactions|length > 0  %}
                                         {% block batch %}
                                         {% block batch %}
                                             <script type="text/javascript">
                                             <script type="text/javascript">
                                                 {% block batch_javascript %}
                                                 {% block batch_javascript %}
@@ -172,7 +174,9 @@ file that was distributed with this source code.
                     {% endif %}
                     {% endif %}
                 {% endblock %}
                 {% endblock %}
             </table>
             </table>
+        {% if admin.hasRoute('batch') %}
         </form>
         </form>
+        {% endif %}
     {% else %}
     {% else %}
         <p class="notice">
         <p class="notice">
             {{ 'no_result'|trans({}, 'SonataAdminBundle') }}
             {{ 'no_result'|trans({}, 'SonataAdminBundle') }}