From c340758aa1ec165dcafafc43afd68b2de69ff050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Proch=C3=A1zka?= Date: Wed, 21 Feb 2024 09:44:50 +0100 Subject: [PATCH] Allow changing modal options through render arguments --- src/AbstractForm.php | 9 ++++++++- src/templates/@layout-modal.latte | 10 ++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/AbstractForm.php b/src/AbstractForm.php index 75cc8dd..d6eba4d 100644 --- a/src/AbstractForm.php +++ b/src/AbstractForm.php @@ -244,9 +244,16 @@ public function renderAccordion(string $container): void } - public function renderModal(): void + public function renderModal(bool $keyboard = false, bool|string $backdrop = 'static'): void { $this->setLayout(Layout::Modal); + $this->onRender[] = fn($self, $template) => $template->setParameters([ + 'modalOptions' => [ + 'data-backdrop' => Format::scalarize($backdrop), + 'data-keyboard' => Format::scalarize($keyboard), + ], + ]); + $this->render(); } diff --git a/src/templates/@layout-modal.latte b/src/templates/@layout-modal.latte index 6215887..1de15e5 100644 --- a/src/templates/@layout-modal.latte +++ b/src/templates/@layout-modal.latte @@ -1,13 +1,15 @@ -