Skip to content

Commit

Permalink
Allow changing modal options through render arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored Feb 21, 2024
1 parent 39b5ac3 commit c340758
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/AbstractForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 6 additions & 4 deletions src/templates/@layout-modal.latte
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<div class="modal fade" id="{$control->getName()}" data-backdrop="static">
<div n:snippet="form">
<div class="modal fade" id="{$control->getName()}" n:attr="... $modalOptions" tabindex="-1">

{default $size = null}

<div n:snippet="form" n:class="modal-dialog, modal-dialog-centered, $size">

{default $hasCloseButton = true}
{default $color = 'secondary'}
{default $contentClass = null}
{default $contentPos = 'top'}
{default $size = null}

<form n:name="form" n:class="modal-dialog, modal-dialog-centered, $size" data-form-name="{$control->getName()}">
<form n:name="form" data-form-name="{$control->getName()}">

<div class="modal-content">

Expand Down

0 comments on commit c340758

Please sign in to comment.