Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MatthieuScarset/f05cc290595861642ffc2ae1d61faa46 to your computer and use it in GitHub Desktop.
Save MatthieuScarset/f05cc290595861642ffc2ae1d61faa46 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment