Skip to content

Instantly share code, notes, and snippets.

@opi
Created April 26, 2021 11:14
Show Gist options
  • Save opi/b855eb28cbeb4d01abe125e8c978d978 to your computer and use it in GitHub Desktop.
Save opi/b855eb28cbeb4d01abe125e8c978d978 to your computer and use it in GitHub Desktop.
Drupal: Do not put buttons into modal/dialog button pane

Do not put buttons into modal/dialog button pane

See https://www.drupal.org/project/drupal/issues/3089751 & https://www.drupal.org/forum/support/theme-development/2018-12-08/prevent-form-actions-from-appearing-in-a-modal-dialog

In mytheme.libraries.yml

dialog.ajax:
  js:
    path/to/js/dialog.ajax.js: { minified: true }

In mytheme.info.yml

libraries-extend:
  core/drupal.dialog.ajax:
    - mytheme/dialog.ajax

Create a file called path/to/js/dialog.ajax.js in your theme, with the following content :

(function (Drupal) {
  // Override core/dialog.ajax prepareDialogButtons behaviors
  Drupal.behaviors.dialog.prepareDialogButtons = function prepareDialogButtons($dialog) {
    // Do nothing = do not put buttons into dialog footer
    return [];
  }
})(Drupal);
@alex-bukach
Copy link

Thank you! It worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment