2022 Developer Survey is open! Take survey.

Questions tagged [modal-dialogs]

Use it for questions about modal popup dialogs, including the overlay implemented in the Drupal 7 Overlay module.

Filter by
Sorted by
Tagged with
1 vote
1 answer
26 views

What is the correct way to set language used by a modal form?

I have a button linked through a controller to open a custom form in a modal: The controller callback is: /** * Callback for opening the modal form. */ public function openShareLinkModalForm(...
user avatar
  • 897
0 votes
1 answer
33 views

How do I make links from views to be opened in modal popups without adding custom rewrite?

I was trying to find if there is a way to avoid writing custom rewrite for links to open in modal popups from a view. Here is what I am rewriting a custom field for doing this now. <a href="...
user avatar
  • 882
1 vote
0 answers
54 views

Ajax drupal dialog doesn't respect dialog-option

I have: $options['attributes']['class'][] = 'use-ajax'; $options['attributes']['data-dialog-type'] = 'modal'; $options['attributes']['data-dialog-options'] = json_encode([ 'width' => 375, ]); ...
user avatar
  • 27.4k
0 votes
0 answers
66 views

How to open a field value dynamically in a modal dialog on node view?

I have a content type with a field, which contains HTML data (a short article). When viewing a node, I want to have a link (or button, doesn't matter), which will open a modal dialog with the value of ...
user avatar
  • 79
0 votes
1 answer
199 views

Use ajax to save modal / dialog form instead of page reload

I'm looking for a way to save modal & dialog forms through ajax instead of redirecting the user after the form submit. Ajax is quite unknown territory to me. I've found several interesting topics ...
user avatar
  • 90
0 votes
1 answer
22 views

Drupal modal does not render remote forms (Mautic)

I'm trying to embed Mautic forms in my drupal site. I created a controller pointing to '/mautic-form` and in the twig template I have this: <script type="text/javascript" src="//...
user avatar
  • 3,421
0 votes
0 answers
34 views

Is there any way to add JS to form only when loaded using ajax-api in modal?

I have one page on which there is a button. On click of that button I am opening a webform in modal popup (Ajax dialog). What I need is to add a GA script to the form. I have tried using ...
user avatar
-2 votes
1 answer
135 views

How to open a form in modal from controller while redirect

I can open a form in modal when click on a link (and there are lot of examples in the net as well). What I like to do: When some one go to a url in browser or redirect to a url, it will open a dialog/...
user avatar
2 votes
1 answer
118 views

Custom Submit Callback only triggering when Form is Valid when in Dialog

I'm trying to create a node in a dialog with the following link: Enter the title of a registration form or <a class="use-ajax" data-dialog-options="{&quot;width&quot;:...
user avatar
  • 1,709
0 votes
1 answer
29 views

Entity Browser Modal closes on Exposed Filter Submit Button

I've set up a commerce shop that uses Entity Browser to select product images. I set up a view to display the selectable images which has an exposed filter for the filename, so the user can search for ...
user avatar
0 votes
0 answers
51 views

Display constraint error in the ajax modal window

From within a form, I have added a link which open a modal form in which I can edit a Paragraph. Here is the code for this link: $form['my_modal_edit_form'] = [ 'title' => $this->t('Edit'), '...
user avatar
  • 554
1 vote
1 answer
495 views

Display status message after submitting modal popup form

Ok so i have a custom entity and want to display a custom delete form. Have created the Route and everything works except for Drupal messenger displaying status message after submission, even after a ...
user avatar
  • 194
1 vote
0 answers
23 views

Dynamically added params for a link not found when the link is opened with a dialog

I do not know if it has to do with JavaScript/Ajax or with Drupal's dialog modal. Any advice is appreciated. On our project we open several links in a modal. For this the link is rendered in the ...
user avatar
0 votes
1 answer
775 views

How do I display a modal dialog on page load, with working title and dialog options, using OpenModalDialogCommand?

I'm trying to display a modal dialog containing some simple markup on page load. I'm getting the expected markup to load, and the dialog appears. However, the dialog title always displays "...
user avatar
  • 177
0 votes
0 answers
126 views

OpenModalDialogCommand without site configuration permission

I have a custom module in Drupal 8.9.9 to open a form in a modal dialog with OpenModalDialogCommand. The custom_modal.routing.yml file has: custom_modal.open_modal_form: path: '/modal_form/{title}/{...
user avatar
  • 55
0 votes
1 answer
83 views

AJAX Modal Form

I created a modal form with Ajax: <?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the ...
user avatar
1 vote
1 answer
597 views

Custom form calls different form in modal, submit/ajax callback of second form not called

I created 2 forms: dms_gift_voucher/src/Form/GiftVoucherForm.php ... /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { .... $...
user avatar
  • 333
1 vote
1 answer
709 views

Show node links in modal buttonpane

I want to show some node fields in buttonpane when I open node in modal. As far as I know, it will automatically show there inputs with type submit and links with class button, but I added class ...
user avatar
  • 1,584
1 vote
2 answers
1k views

Add event listener to modal close

In Drupal we can open a modal is two ways, either with HTML: <a class="use-ajax profile-page-link" data-dialog-type="modal" href="/node/1" data-dialog-options="{&...
user avatar
  • 6,343
3 votes
1 answer
1k views

Open ajax dialog with JavaScript

By adding use-ajax to a link we can open a modal using the Drupal ajax library as per the docs. E.g. <a class="use-ajax" data-dialog-options="{&quot;width&quot;:400}&...
user avatar
  • 6,343
2 votes
2 answers
499 views

Using attach_library in a modal

For ref, I'm working on https://www.drupal.org/project/focal_point/issues/3162218 I have a twig file that handles the contents of a modal window and I want to load a particular CSS file whenever this ...
user avatar
  • 1,490
1 vote
1 answer
81 views

Form in modal dialog: Template suggestions have weird random suffix

My custom module has the following form route in mymodule.routing.yml: library_assets.add_asset_to_slideshow_modal: path: 'library/add-to-slideshow-modal/{library_asset_nid}' defaults: _form: ...
user avatar
0 votes
0 answers
90 views

Replace the default modal with a different one

I want to replace Drupal 8 default modal with MDB. How I can do it? Should I unload default library for modals and load new one? Any idea?
user avatar
  • 1,584
0 votes
1 answer
57 views

Popups & colorbox issues in Chrome

Hoping for some guidance here. Sometime in the past few weeks, my inline modal popups stopped working in Chrome. I had Colorbox set up at the time, both hand coded inline links and views colorbox ...
user avatar
  • 21
1 vote
1 answer
152 views

How do form #states interact with dialog action buttons, if at all?

A dialog can be fired by a link formatted as such: <a class="use-ajax" data-dialog-options="{&quot;width&quot;:400}" data-dialog-type="modal" href="/some/path"> Some ...
user avatar
  • 1,761
0 votes
0 answers
1k views

Programmatically get the current url of the page from where a Webform in a dialog has been loaded

The below link will open the webform (contact) in a dialog: <a href="/form/contact" class="btn btn-success webform-dialog webform-dialog-normal">Contact</a> this same link has been ...
user avatar
3 votes
1 answer
2k views

How do I theme the core modal with twig?

Drupal 8 comes with built in modals. This works: <a href="/node/11" class="use-ajax" data-dialog-type ="modal">modal</a> How can I style that modal using twig, to add new classes to the ...
user avatar
  • 156
1 vote
1 answer
159 views

How to have a dialog box displayed automatically when a page is reached without having to click the link?

Using Dialog API and advice from @leymannx, I added this link to a node (node99): <a class="use-ajax" data-dialog-options="{&quot;width&quot;:600}" data-dialog-type="modal" href="/node/...
user avatar
  • 960
2 votes
1 answer
362 views

How to populate an Entity Reference field from a modal AjaxResponse?

I have an entity ref autocomplete field (reference to bundle A) in one of my bundles (bundle B). I want to add a button below this field which will open a modal for a bundle A create form. This code ...
user avatar
  • 897
0 votes
1 answer
298 views

Creating ajax modal from event

Here's the deal. I want to create a modal popup when an add to cart event is triggered. I've got the event working just fine but can't seem to get the ajax to work properly. What I'm working off of ...
user avatar
  • 195
1 vote
1 answer
613 views

How to get node title using this query on template?

Im building a custom filter in Drupal 8 based on some queries. I got this already, here im filtering by values on body: $query = db_select('node__body', 'n') ->fields('...
user avatar
1 vote
1 answer
39 views

Issue regading custom form

https://wineshipinsure.com/newdrupal/ex81/helloform I have been using the custom form and followed all the process for creating the custom form but my form is not working and every time getting page ...
user avatar
0 votes
1 answer
230 views

How to open a link in ctools modal by clicking a views row in table format?

I want to open a page in ctools modal. This works for me. <a href="/my-page/nojs" class="ctools-use-modal">Click</a> But now I want to open the same page in ctools modal by clicking the ...
user avatar
  • 2,699
0 votes
0 answers
53 views

SweetAlert doesn't display content markup

The SweetAlert modal is not displaying the content as passed in the option array when returning a response from the controller. Please see the code config below: //$options = ...
user avatar
1 vote
0 answers
36 views

8 - How can I update the entity reference fields of the form when I close the modal?

How can I update the entity reference fields of the form based on selection in the modal dialog when I close the modal ? I have a form and users starts fill the form. Then click on choose address ...
user avatar
-1 votes
1 answer
61 views

on click popup load another popup and close other popup

I'm having a requirement where I have to show popup on the click link. and then after that pop up open need to show related content on that pop-up. this part is working. by doing this <a class="...
user avatar
  • 145
0 votes
1 answer
338 views

How to get my button in a dialog click?

I have added the following JS to a node form, it clones the submit button but clicking it inside the dialog (which does show up) doesn't submit the form in the browser, just nothing happens when the ...
user avatar
0 votes
1 answer
219 views

Show rendered node in jQuery modal through JSON

Whenever a link has a specific class I want to show it as a jQuery modal. I have added the neccesarry data attributes to the link in order to be able to use it as a modal. I have also created a route ...
user avatar
0 votes
1 answer
230 views

Create a modal popup

I want to show a modal popup in drupal 7. On searching the web I came to know that it can be done using the ctools module itself. Here is the code I tried: function codeexpertz_menu() { $items['...
user avatar
1 vote
1 answer
581 views

How do I use Bootstrap theme's modal.jquery.ui.bridge's mapped events?

I am using a Bootstrap subtheme, and would like to trigger an event when a modal is closed. Reviewing the main theme's modal.jquery.ui.bridge.js file, I see that the bridge is intending to map jQuery ...
user avatar
  • 562
0 votes
1 answer
44 views

Modal dialog doesn't work

I want to display ctools modal. I tried the following code. /** * Implements hook_menu(). */ function my_module_menu() { $items['my_module/%ctools_js/test-page'] = array( 'title' => 'Demo ...
user avatar
  • 2,699
1 vote
1 answer
87 views

Modal does not handle errors on login

I have used 'use-ajax' class to render login form in a modal. I want to handle validation errors on same modal without closing it. On successful login it is redirecting correctly, but when an error ...
user avatar
0 votes
2 answers
2k views

How to open a node edit form in an overlay (modal window) in Drupal 8

I have a view with nodes of type 'tasks'. I want to easily view and edit these tasks by using a minimized overlay. When I click on a task title in the view, it needs to open in an overlay. In D7 this ...
user avatar
  • 586
0 votes
1 answer
793 views

How do I trigger a modal from a template that points to a controller returning an AJAX response

I am trying to trigger a modal from a twig. The path of the modal is a controller that returns an AJAX response as below: Routing code usgbc_myaccount.get_badges_evidence_controller: path: '/account/...
user avatar
1 vote
1 answer
3k views

How do you create a link to a modal dialog?

The following code does not work: <div class="topics"><a class="use-ajax" data-dialog-type="modal" href="/topics-listing">All Topics</a></div> Drupal 8.6.5. Bootstrap ...
user avatar
0 votes
1 answer
2k views

How to display a form in modal dialog on page load?

This is on Drupal 8.6, PHP 7.2, Theme is based on Bootstrap. The scenario is, I want to display a dialog box with a subscription form in the home page. The dialog box will be loaded automatically ...
user avatar
0 votes
1 answer
408 views

Modal Form Submission

I have a modal form that I added to my module and patterned it after this article. I have used it before with no issues, I was able to use the method to show the form and then save the data. Now ...
user avatar
2 votes
1 answer
1k views

How can I add animation/fade to modal/dialogue boxes?

The current state of a modal/dialog opening in Drupal 8 (and 7 for that matter) is pretty clunky from a user experience perspect. Leveraging some type of animation/fade would really enhance the ...
user avatar
8 votes
0 answers
1k views

How do I theme a modal popup?

How can I style Drupal 8 modal window to achieve Instagram style and behaviour? I'm creating modal through extending ControllerBase class, thus have full control of content. However I can't figure it ...
user avatar
  • 81
1 vote
0 answers
62 views

Open Paragraphs-item into an entityform

I have a profile page with many paragraph sections. I am trying to open the input form for every paragraph separately into a modal form. I don't want to manually build a form for each paragraph. The ...
user avatar
  • 11