This project is not covered by Drupal’s security advisory policy.
Links to webforms that behave on their own. Put /form/your-form in any link field and it opens in a modal and records the page (node, product, term…) the visitor came from, with no code.
Sites often need a "Request a quote", "Book now" or "Contact us about this" button on many pages, pointing to one webform. Out of the box, Drupal has two problems with that. The link opens the form on a separate page instead of a dialog, unless editors type CSS classes and data attributes by hand. And the submission does not know which page the visitor came from, because Drupal core does not support dynamic values in the URL of a link field.
This module fixes both. Any link field that points to a webform becomes a Drupal modal link automatically. On the page of an entity, the link also carries that entity's type and ID. Webform already reads those two parameters and saves the entity as the submission's source entity, so each submission records its origin.
New to Drupal? Think of it this way: you have 80 tour pages and one "Request a quote" button that is shared by all of them. With this module, the button opens the quote form in a pop-up on top of the tour page, and every quote you receive tells you which tour the visitor was looking at. You don't need a developer, and you don't need one form per tour.
Features
The module does not add fields, formatters or content types. It changes how existing links to webforms behave, wherever a link field is displayed. The two features can be turned on or off separately:
- Open in a dialog. Links to a webform get
use-ajax,data-dialog-type="modal"and the dialog options, and the dialog library is attached for them. Editors only enter/form/contact. - Pass the source entity. On an entity page, the link gets
source_entity_typeandsource_entity_idfor that entity. It works with any content entity type: nodes, taxonomy terms, users, Commerce products, custom entities… Webform's built-inQueryStringWebformSourceEntityplugin reads them, so the submission and its tokens ([webform_submission:source-entity:*]) know where it came from. - Respects what is already there. Links that already set a dialog (
data-dialog-type) are left as they are. Webforms with a page URL of their own (Page URL alias) stay pages. Webforms that do not accept a source entity from the URL do not get the parameters. - Dialog options globally and per webform. You can set the width, a CSS class for your theme, and whether the submit buttons stay inside the form instead of moving to the dialog's button bar.
- Works wherever a link field is displayed. This includes entity view modes, Views fields and Layout Builder field blocks. It applies to any field whose type is, or extends,
link. - Safe with Drupal's cache. A shared link (a content block, a view or a paragraph shown on many pages) is rendered once and cached. If its URL depended on the page but its cache entry did not, every page would serve the first page's URL. Every lead would be recorded with the wrong origin, and nothing on the site would show the error. The module adds its own
route.page_entitycache context to every link it may rewrite. That context gives each entity page its own cached variation, and all pages without an entity share one. An automated kernel test covers this.
When and why would someone use this module? Use cases include:
- Travel and tours: A "Request a quote" button on every tour page, with the tour recorded in each request.
- E-commerce and catalogs: "Ask about this product" or "Request a demo" forms that know which product the visitor was looking at.
- Real estate, events, jobs: "Contact the agent", "Register" or "Apply" buttons that save the property, event or job offer with the submission.
- Header and banner calls to action: "Contact us" or "Book your spot" buttons in menus, alerts or hero blocks that open the form in a pop-up instead of leaving the page.
- CRM and marketing integrations: Webform handlers that send submissions to a CRM receive the source entity too, so every lead arrives with its context.
Post-Installation
Both features work as soon as the module is enabled. It does not create configuration pages of its own; its settings live in Webform's screens:
- In any link field (a block, a menu CTA, a hero, a paragraph…), link to a webform:
/form/contact, or pick the webform with the autocomplete. - For the source entity: edit the webform, go to Settings → Form → Form behaviors and enable Allow (only) the source entity to be populated using query string parameters. Optionally, restrict the source entity type. Webforms without this setting do not receive the parameters, because Webform would ignore them.
- Global settings: Structure → Webforms → Configuration → Forms → Third party settings → Links to webforms. Here you turn each feature on or off and set the default dialog width, CSS class and button behavior.
- Per-webform settings: edit the webform, then Settings → General → Third party settings → Links to this webform. Anything left empty uses the global settings.
- To submit without leaving the dialog, enable Use Ajax in the webform's settings (Settings → Form).
Clear caches (drush cr, or Administration → Configuration → Performance) after enabling the module, so that pages cached before it was enabled pick up the new links.
Additional Requirements
No external libraries or APIs. The requirements are:
- Drupal core
^11.1(the module uses object-oriented#[Hook]classes). - Core Link module.
- Webform
^6.3.
Recommended modules/libraries
- Current Page Entity Tokens: Provides tokens for the entity of the current page. It is a good fit for a webform embedded in the page. It cannot fill a dialog, because the dialog is loaded by a separate request to the webform, where the "current page" is the form itself. This module covers that case.
Similar projects
-
Webform's built-in dialog support: Webform can open links in a dialog when the site-wide dialog setting is enabled. Editors then add classes such as
webform-dialog webform-dialog-normalto each link by hand, which needs a module that exposes link attributes, and can useENTITY_TYPE/ENTITY_IDplaceholders that are replaced in the browser. This module needs no classes or placeholders from the editor, builds the final URL on the server so it works without JavaScript, and handles the caching of shared links. -
Link Attributes: Lets editors type attributes such as
classordata-*on each link. It can reproduce the dialog by hand, link by link, but it cannot add the entity of the page, which changes from page to page. - Current Page Entity Tokens: See above. It provides tokens rather than link behavior, and link fields do not support tokens in their URL (core issue #2903336).
- Webform entity reference field ("Webform node"): Embeds a webform inside each entity and records that entity as the source. It is a good choice when every page carries its own form. This module is for the opposite case: one webform, linked from many pages, opened in a dialog.
Recommended projects
I also maintain the following modules. They extend Drupal's native systems instead of replacing them, and they work alongside this one:
- CKEditor Advanced Container: Flexbox containers and responsive columns inside CKEditor 5, configured from the editor, with no CSS framework.
- CKEditor Content Groups: Accordions and horizontal/vertical tabs inside CKEditor 5.
- Schema.org Mapper: Maps your entities and fields to Schema.org structured data.
- Admin Navigation: Extends Drupal's administration navigation.
Commercial Support
This module is developed and maintained by Nelo.
The maintainer is available for professional consulting and architectural guidance on Webform integrations, lead capture and CRM workflows, caching, and production Drupal implementations.
Supporting this Module
- Check out our sponsor, Dom Host Seo, who made this module possible with their support!
Community Documentation
Currently no external videos or demo sites are available. The module's README.md explains the configuration and how caching is handled. The kernel test WebformLinkExtrasTest shows the expected behavior, including the shared-block cache case.
For questions, bug reports, or feature requests, please use the issue queue on Drupal.org.
Roadmap
Planned features, all about how a link to a webform behaves:
- Hide or disable the link while the webform is closed (scheduled open/close).
- Prefill webform elements from the entity of the page.
- Tell visitors when they have already submitted a webform that has a submission limit.
- Send visitors back to the page they came from after submitting.
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.Maintenance fixes only
Considered feature-complete by its maintainers.- Project categories: Administration tools, Integrations
- Created by nelo_drup on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
Releases
First stable release: links to webforms open in a dialog and record the page they came from as source entity.