Skip to content

Commit

Permalink
If FormProtectorComponent is not loaded, FormHelper::unlockField() th…
Browse files Browse the repository at this point in the history
…rows an exception
  • Loading branch information
ADmad committed Jul 9, 2024
1 parent fe50b47 commit 25640c1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/View/Helper/CrudViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 25640c1

Please sign in to comment.