Prechádzať zdrojové kódy

Fix filtering parameters

Thomas Rabaix 12 rokov pred
rodič
commit
caf67ae9e0

+ 5 - 5
Controller/CRUDController.php

@@ -188,7 +188,7 @@ class CRUDController extends Controller
             $this->get('session')->setFlash('sonata_flash_error', 'flash_batch_delete_error');
         }
 
-        return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
+        return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters())));
     }
 
     /**
@@ -386,16 +386,18 @@ class CRUDController extends Controller
             $nonRelevantMessage = 'flash_batch_empty';
         }
 
+        $datagrid = $this->admin->getDatagrid();
+        $datagrid->buildPager();
+
         if (true !== $nonRelevantMessage) {
             $this->get('session')->setFlash('sonata_flash_info', $nonRelevantMessage);
 
-            return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
+            return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters())));
         }
 
         $askConfirmation = isset($batchActions[$action]['ask_confirmation']) ? $batchActions[$action]['ask_confirmation'] : true;
 
         if ($askConfirmation && $confirmation != 'ok') {
-            $datagrid = $this->admin->getDatagrid();
             $formView = $datagrid->getForm()->createView();
 
             return $this->render('SonataAdminBundle:CRUD:batch_confirmation.html.twig', array(
@@ -412,8 +414,6 @@ class CRUDController extends Controller
             throw new \RuntimeException(sprintf('A `%s::%s` method must be created', get_class($this), $final_action));
         }
 
-        $datagrid = $this->admin->getDatagrid();
-        $datagrid->buildPager();
         $query = $datagrid->getQuery();
 
         $query->setFirstResult(null);

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

@@ -22,7 +22,7 @@ file that was distributed with this source code.
 {% block list_table %}
     {% set batchactions = admin.batchactions %}
     {% if admin.datagrid.results|length > 0 %}
-        <form action="{{ admin.generateUrl('batch', admin.filterParameters) }}" method="POST" >
+        <form action="{{ admin.generateUrl('batch', {'filter': admin.filterParameters}) }}" method="POST" >
             <table class="table table-bordered table-striped">
                 {% block table_header %}
                     <thead>
@@ -207,5 +207,4 @@ file that was distributed with this source code.
             </fieldset>
         </form>
     {% endif %}
-{% endblock %}
-
+{% endblock %}

+ 5 - 6
Resources/views/CRUD/batch_confirmation.html.twig

@@ -15,13 +15,13 @@ file that was distributed with this source code.
     <div class="sonata-actions">
         {% if admin.hasRoute('list') and admin.isGranted('LIST')%}
             <a class="btn sonata-action-element" href="{{ admin.generateUrl('list') }}">
-                <i class="icon-list"></i>
-                {{ 'link_action_list'|trans({}, 'SonataAdminBundle') }}</a>
+                <i class="icon-list"></i> {{ 'link_action_list'|trans({}, 'SonataAdminBundle') }}
+            </a>
         {% endif %}
         {% if admin.hasRoute('create') and admin.isGranted('CREATE')%}
             <a class="btn sonata-action-element" href="{{ admin.generateUrl('create') }}">
-                <i class="icon-plus"></i>
-                {{ 'link_action_create'|trans({}, 'SonataAdminBundle') }}</a>
+                <i class="icon-plus"></i>{{ 'link_action_create'|trans({}, 'SonataAdminBundle') }}
+            </a>
         {% endif %}
     </div>
 {% endblock %}
@@ -30,7 +30,6 @@ file that was distributed with this source code.
 
 {% block content %}
     <div class="sonata-ba-delete">
-
         <h1>{{ 'title_batch_confirmation'|trans({}, 'SonataAdminBundle') }}</h1>
 
         {% if data.all_elements %}
@@ -40,7 +39,7 @@ file that was distributed with this source code.
         {% endif %}
 
         <div class="well form-actions">
-            <form action="{{ admin.generateUrl('batch', admin.filterParameters) }}" method="POST" >
+            <form action="{{ admin.generateUrl('batch', {'filter': admin.filterParameters}) }}" method="POST" >
                 <input type="hidden" name="confirmation" value="ok" />
                 <input type="hidden" name="data" value="{{ data|json_encode }}" />