Webforms on a static site with Quant Forms
A static page has no Drupal behind it to take a form submission. With the quant_webform submodule (module 2.3.0 and later, Drupal 11), Quant Forms takes the submissions of your Webforms instead: Quant stores each submission, sends the email and Slack notifications, and shows the confirmation. Your live Drupal site keeps working as before, because only the copy that Quant publishes is changed.
- Connect Drupal with Quant
- Install the Webform module and enable the
quant_webformsubmodule (drush en quant_webform, or tick Quant webform on Extend (/admin/modules) and click Install) - On each Webform, turn off “Use Ajax” (Settings > General > Ajax settings). An AJAX form posts to Drupal, so the module does not register it
- Opt each form in. Quant Forms is off for every Webform until you tick
Take submissions through Quant Formsin the form’s Quant Forms settings, or tick the form on the Quant Forms page (/admin/config/development/quant/forms) and clickRegister the ticked forms, or run:
drush quant:webform-register contact --opt-inThe command publishes the page of the form with its Quant Forms settings and prints anything that will not work on the static site. Without --opt-in it publishes only forms that are already ticked.
On the Quant Forms page, Register the ticked forms shows “Quant Forms is on for N forms.” A form that you tick there for the first time is saved, and its page is published at once if the form is open. The page of a form that was already ticked is queued instead, and the message adds “N pages are queued to publish again on the next cron run (or drush quant:run-queue).” Run drush quant:run-queue, or wait for cron, before you test that form on the static site.
What the module sends to Quant
Section titled “What the module sends to Quant”When Quant publishes the page that takes a Webform’s submissions, the module adds the form settings to that page:
| From the Webform | In Quant Forms |
|---|---|
| Elements that are always required (no conditions on them or on a parent) | Mandatory fields. For an address or other composite, the parts that are marked required, for example address[city] |
| Drupal’s own hidden fields and file id fields | Removed before the submission is stored |
| The Honeypot module field, when Honeypot protects the form | Honeypot field |
| A reCAPTCHA v2 element | reCAPTCHA check |
| The confirmation message, without tokens, or the static message set for the form | Success message |
| The first enabled email handler that runs on “completed” | Email notification (to, cc, from, subject, reply-to). [webform_submission:values:email] in the subject or reply-to becomes {{email}} |
| The Slack webhook on the Quant Forms page | Slack notification |
| The AI spam check on the Quant Forms page | Spam score threshold and action |
The page that takes the submissions is the Webform’s own page (for example /contact-us). A Webform that is also shown in a block, a footer or a node posts to that page from everywhere, so a newsletter form in the footer of every page has one set of Quant Forms settings. A Webform without its own page posts to the node page that shows it.
Closing or deleting a Webform turns Quant Forms off for its page. Quant keeps the submissions that it already has.
Per-form settings
Section titled “Per-form settings”Each Webform has a “Quant Forms” section under Settings > General > Third party settings. For a ticked form you make every Quant Forms setting here, so you do not need the dashboard:
- Take submissions through Quant Forms: off until you tick it
- Notification email: from the first email handler of the form (the default), set here (to, cc, from, reply-to, subject;
{{field}}works in the subject and reply-to), or no email - Slack: on or off, with a webhook for this form or the site webhook from the Quant Forms page
- Spam protection: a hidden honeypot field, a reCAPTCHA v2 checkbox (site key and secret key), the AI spam check, and refused countries and IP addresses
- After a submit: as the Webform’s confirmation says, a message in place of the form, or another page
The Slack webhook and the reCAPTCHA secret are kept outside Drupal configuration, so a configuration export never contains them, and the form shows them masked. Features that Quant Forms cannot do are listed in the section, greyed out, with the reason. The section also shows what of the form works on the static site, and the page that takes its submissions.
Quant Forms is turned off on a page that the module registered when that page no longer shows a ticked form, or when the form is unticked, closed (also by its schedule, on the next cron run) or deleted. Pages that you set up in the dashboard and never ticked in Drupal are not changed.
Multi-page forms
Section titled “Multi-page forms”Multi-page Webforms work on the static site. Quant publishes every page of the form in one static page, and a script shows one step at a time:
Continuechecks the fields of the current step in the browser before the next step shows. Conditional fields that are hidden are not checked, and pages hidden by conditions are skipped- A review step lists the answers when the Webform has a preview
- The form posts once, at the end, and the confirmation shows in place of the form. A “redirect to URL” confirmation goes to that URL
- Each file of a multi-file upload field is kept
Without JavaScript all pages show at once and the form posts as one page.
What works on the static site
Section titled “What works on the static site”| Webform feature | On the static site |
|---|---|
| Single-page and multi-page forms, preview | Supported |
Conditions (#states) |
Supported in the browser |
| Text, email, telephone, URL, number, date, text area, select, radios, checkboxes, single checkbox, hidden, Likert | Supported |
| Address, name, contact and custom composite elements | Supported |
| File uploads | Supported. Without JavaScript, only the last file of a multi-file field is kept |
| Email handler | Supported (the first enabled one) |
| Honeypot, reCAPTCHA v2, AI spam check | Supported |
| Confirmation types message, inline, page, modal | Shown in place of the form |
| Confirmation types url, url_message | Redirect after the submit |
What does not work on the static site
Section titled “What does not work on the static site”| Webform feature | Why |
|---|---|
| AJAX submit | The form would post to Drupal. The module does not register it until “Use Ajax” is off |
| Save draft | Drafts are kept by Drupal. The button is removed on the static site |
| Submission limits | Quant does not count submissions per form |
| Handlers other than email, for example remote post | They run in Drupal. Quant stores the submission instead |
| Computed elements | They are computed by Drupal |
| CAPTCHA other than reCAPTCHA v2 (for example Turnstile, hCaptcha, image CAPTCHA) | Quant checks reCAPTCHA v2 only |
Submission tokens such as [webform_submission:serial] |
No server renders them. They are removed from messages, so set a static message for the form |
| Two forms on one page that have no page of their own | Quant keeps one set of settings per page. The first form is registered and Drupal logs a warning |
Find the submissions
Section titled “Find the submissions”Submissions are in the Quant dashboard under Forms, and in the Content API: see the /form-submissions endpoint, with the Quant-Url header set to the page path.
