From cdfad6fc561e497a4bdea39e04237ac676728121 Mon Sep 17 00:00:00 2001 From: Stef Liekens Date: Fri, 10 Jul 2015 15:32:32 +0200 Subject: [PATCH] Redirect in the controller may not occurred while deleting entities via an ajax request --- src/Phpro/SmartCrud/Controller/CrudController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Phpro/SmartCrud/Controller/CrudController.php b/src/Phpro/SmartCrud/Controller/CrudController.php index ecb1a0f..5912a23 100644 --- a/src/Phpro/SmartCrud/Controller/CrudController.php +++ b/src/Phpro/SmartCrud/Controller/CrudController.php @@ -159,9 +159,10 @@ public function readAction() */ public function deleteAction() { - $data = $this->getRequest()->isPost() ? $this->getRequest()->getPost() : null; + $request = $this->getRequest(); + $data = $request->isPost() ? $request->getPost() : null; $result = $this->getSmartService()->run($this->getEntityId(), $data); - if ($this->getRequest()->isPost() && $result->isSuccessFull()) { + if (($request->isPost() && !$request->isXmlHttpRequest()) && $result->isSuccessFull()) { return $this->redirect()->toRoute(null, array('action' => 'list'), true); } return $this->getViewModelBuilder()->build($this->getRequest(), $result, 'delete');