Problem/Motivation
It seems that there is no option through HTML attribute to configure the Bootstrap settings such as backdrop, keyboard and focus. The additional options are particularly useful, especially when the modal content is a form. The keyboard option can prevent unintended closure of the modal unless the close button is clicked.
Proposed resolution
To add new settings for backdrop, keyboard and focus in data-dialog-options.
{% set
defaultOptions = {
autoOpen: 'true',
dialogClasses: '',
dialogShowHeader: 'true',
dialogShowHeaderTitle: 'true',
buttonClass: 'btn',
buttonPrimaryClass: 'btn-primary',
keyboard: 'true',
focus: 'true',
backdrop: 'static',
}
%}
<a href="/" class="use-ajax" data-dialog-type="bootstrap4_modal" data-dialog-options="{{ defaultOptions|json_encode }}">Open in Bootstrap Modal</a>
Comments
Comment #2
madelyncruz commentedComment #3
madelyncruz commentedComment #5
madelyncruz commentedComment #6
madelyncruz commentedComment #8
vhin0210 commentedComment #10
sneakysnk commentedSorry if I'm mistaken but it doesn't work.
This code always returns true. No matter the value you send, a falsy value directly returns true due to the ternary condition. And if you try to send 'false' (string) to bypass this, Boolean('false') converts it to true anyway.
So it's impossible to set these values as false.