From 25640c1aea2cc2aa2cf4c4c9ca68bd58bd7bfa73 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 9 Jul 2024 17:26:09 +0530 Subject: [PATCH] If FormProtectorComponent is not loaded, FormHelper::unlockField() throws an exception --- src/View/Helper/CrudViewHelper.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/View/Helper/CrudViewHelper.php b/src/View/Helper/CrudViewHelper.php index f7436a4..ed3c01c 100644 --- a/src/View/Helper/CrudViewHelper.php +++ b/src/View/Helper/CrudViewHelper.php @@ -4,6 +4,7 @@ namespace CrudView\View\Helper; use BackedEnum; +use Cake\Core\Exception\CakeException; use Cake\Database\Type\EnumLabelInterface; use Cake\Datasource\EntityInterface; use Cake\Datasource\SchemaInterface; @@ -347,7 +348,11 @@ public function redirectUrl(): ?string return null; } - $this->Form->unlockField('_redirect_url'); + try { + $this->Form->unlockField('_redirect_url'); + } catch (CakeException) { + // If FormProtectorComponent is not loaded, FormHelper::unlockField() throws an exception + } return $this->Form->hidden('_redirect_url', [ 'name' => '_redirect_url',