From fe5ba3918dce3211cf15a5275d1abe151e2454e0 Mon Sep 17 00:00:00 2001 From: pxpm Date: Tue, 11 Nov 2025 11:11:41 +0000 Subject: [PATCH] add cancel button option to modal form --- src/app/View/Components/Dataform.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/View/Components/Dataform.php b/src/app/View/Components/Dataform.php index f106a9c9a6..49fb861ca0 100644 --- a/src/app/View/Components/Dataform.php +++ b/src/app/View/Components/Dataform.php @@ -18,6 +18,7 @@ class Dataform extends Component * @param string|null $action Custom form action URL * @param string $method Form method (post, put, etc.) * @param bool $focusOnFirstField Whether to focus on the first field when form loads + * @param bool|null $showCancelButton Override for the CRUD cancel button visibility */ public function __construct( public string $controller, @@ -30,6 +31,7 @@ public function __construct( public $entry = null, public ?Closure $setup = null, public bool $focusOnFirstField = false, + public ?bool $showCancelButton = null, public bool $formInsideCard = false, public array $saveActions = [], ) { @@ -71,6 +73,10 @@ public function __construct( call_user_func($this->setup, $this->crud, $parentEntry); } + if (! is_null($showCancelButton)) { + $this->crud->setOperationSetting('showCancelButton', $showCancelButton); + } + // Reset the active controller CrudManager::unsetActiveController(); }