Open Drupal 8 Webform in Modal

Creating a webform modal is quite simple and straight forward in Drupal 8.

We only need the Webform module and some classes for the modal opening button:

  1. Download and install https://www.drupal.org/project/webform
  2. Create a webform
  3. Check (allow) the webform decicated URL option in the webform settings: /structure/webform/manage/MYFORM/settings:
  4. Optionally change the URL or leave the field empty to use the default (see help icon)
  5. Optionally allow parameter prepopulation in fields, if you'd like to provide a parameter via webform URL
  6. Add the class "use-ajax" and the data attribute: "data-dialog-type='modal'" to your trigger button:

    <a href="internal:en/form/your-form-name?&webform_parameter1=abc" class="use-ajax" data-dialog-type="modal">Open webform in Modal</a>

  7. Add modal styling, if required

That's it! :)

More information (but a bit older): https://www.previousnext.com.au/blog/understanding-drupal-8s-modal-api-a...

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.

More information about formatting options