From 04ad3be4a6ab9e14e69eeed6c11f488b9451b4ea Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Tue, 9 Nov 2021 09:15:19 +0100 Subject: [PATCH] fix: [component:CRUD] Correctly inspect the redirect key --- src/Controller/Component/CRUDComponent.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index 4331e35..03e211c 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -750,7 +750,7 @@ class CRUDComponent extends Component if ($this->Controller->ParamHandler->isRest()) { $this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json'); } elseif ($this->Controller->ParamHandler->isAjax()) { - if ($additionalData['redirect']) { // If a redirection occors, we need to make sure the flash message gets displayed + if (!empty($additionalData['redirect'])) { // If a redirection occurs, we need to make sure the flash message gets displayed $this->Controller->Flash->success($message); } $this->Controller->ajaxResponsePayload = $this->RestResponse->ajaxSuccessResponse($this->ObjectAlias, $action, $data, $message, $additionalData); @@ -762,7 +762,7 @@ class CRUDComponent extends Component if ($this->Controller->ParamHandler->isRest()) { $this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json'); } elseif ($this->Controller->ParamHandler->isAjax()) { - if ($additionalData['redirect']) { // If a redirection occors, we need to make sure the flash message gets displayed + if (!empty($additionalData['redirect'])) { // If a redirection occors, we need to make sure the flash message gets displayed $this->Controller->Flash->error($message); } $this->Controller->ajaxResponsePayload = $this->RestResponse->ajaxFailResponse($this->ObjectAlias, $action, $data, $message, !is_null($errors) ? $errors : $data->getErrors());