settings.dialog is undefined with modal form

Created on 6 September 2023, over 1 year ago

Problem/Motivation

I want to open a modal form into a standard form. I setup a link to open the modal.

  $form['actions']['suspend'] = [
    '#type' => 'link',
    '#title' => t('Save Cart'),
    '#url' => Url::fromRoute('oto_commerce_cart_suspended.suspended_form'),
    '#attributes' => [
      'class' => [
        'use-ajax',
        'button',
        'btn btn-primary'
      ],
    ],
    '#weight' => 100
  ];

  // Attach the library for pop-up dialogs/modals.
  $form['#attached']['library'][] = 'core/drupal.dialog.ajax';

When i try my code into gin theme i don't have problem. code works fine.
When i try to use into frontend theme i get this error:

Uncaught TypeError: settings.dialog is undefined
    attach https://localhost/core/misc/dialog/dialog.ajax.js?v=9.5.10:21
    attachBehaviors https://localhost/core/misc/drupal.js?v=9.5.10:24
    attachBehaviors https://localhost/core/misc/drupal.js?v=9.5.10:21
    <anonymous> https://localhost/core/misc/drupal.init.js?v=9.5.10:24
    listener https://localhost/core/misc/drupal.init.js?v=9.5.10:14
    domReady https://localhost/core/misc/drupal.init.js?v=9.5.10:20
    <anonymous> https://localhost/core/misc/drupal.init.js?v=9.5.10:23
    <anonymous> https://localhost/core/misc/drupal.init.js?v=9.5.10:26

what is missing?
Thank you

💬 Support request
Status

Active

Version

9.5

Component
Ajax 

Last updated 1 day ago

Created by

🇮🇹Italy trickfun

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024