Procházet zdrojové kódy

Keep original ParameterBag after confirming a batch action.

Romain Geissler před 13 roky
rodič
revize
045338f2f4
1 změnil soubory, kde provedl 18 přidání a 17 odebrání
  1. 18 17
      Controller/CRUDController.php

+ 18 - 17
Controller/CRUDController.php

@@ -321,9 +321,12 @@ class CRUDController extends Controller
             $idx    = $data['idx'];
             $idx    = $data['idx'];
             $all_elements = $data['all_elements'];
             $all_elements = $data['all_elements'];
         } else {
         } else {
+            $this->get('request')->request->set('all_elements', $this->get('request')->get('all_elements', false));
+
             $action       = $this->get('request')->get('action');
             $action       = $this->get('request')->get('action');
             $idx          = $this->get('request')->get('idx');
             $idx          = $this->get('request')->get('idx');
-            $all_elements = $this->get('request')->get('all_elements', false);
+            $all_elements = $this->get('request')->get('all_elements');
+            $data         = $this->get('request')->request->all();
         }
         }
 
 
         $batchActions = $this->admin->getBatchActions();
         $batchActions = $this->admin->getBatchActions();
@@ -339,22 +342,20 @@ class CRUDController extends Controller
 
 
         $askConfirmation = isset($batchActions[$action]['ask_confirmation']) ? $batchActions[$action]['ask_confirmation'] : true;
         $askConfirmation = isset($batchActions[$action]['ask_confirmation']) ? $batchActions[$action]['ask_confirmation'] : true;
 
 
-        if ($askConfirmation && $this->get('request')->get('confirmation') != 'ok') {
-            $data = json_encode(array(
-                'action' => $action,
-                'idx'    => $idx,
-                'all_elements' => $all_elements,
-            ));
-
-            $datagrid = $this->admin->getDatagrid();
-            $formView = $datagrid->getForm()->createView();
-
-            return $this->render('SonataAdminBundle:CRUD:batch_confirmation.html.twig', array(
-                'action'   => 'list',
-                'datagrid' => $datagrid,
-                'form'     => $formView,
-                'data'     => $data,
-            ));
+        if ($askConfirmation) {
+            if ($this->get('request')->get('confirmation') != 'ok') {
+                $datagrid = $this->admin->getDatagrid();
+                $formView = $datagrid->getForm()->createView();
+
+                return $this->render('SonataAdminBundle:CRUD:batch_confirmation.html.twig', array(
+                    'action'   => 'list',
+                    'datagrid' => $datagrid,
+                    'form'     => $formView,
+                    'data'     => json_encode($data),
+                ));
+            } else {
+                $this->get('request')->request->replace($data);
+            }
         }
         }
 
 
         // execute the action, batchActionXxxxx
         // execute the action, batchActionXxxxx