Webform

A comprehensive form builder and submission manager for Drupal that enables creation of webforms and questionnaires with extensive customization options.

webform
342,228 sites
431
drupal.org

Install

Drupal 10 v6.2.9
composer require 'drupal/webform:^6.2'

Overview

The Webform module is a powerful form builder and submission manager for Drupal 10/11. It provides all the features expected from an enterprise proprietary form builder combined with the flexibility and openness of Drupal.

The primary use case for this module is to: Build a new webform or duplicate an existing template; Publish the webform as a page, node, or block; Collect submissions; Send confirmations and notifications; Review submissions online; Download submissions as CSV.

The module is built directly on top of Drupal's Form API, supporting every form element available in Drupal. It offers 80+ form element types, conditional logic, multi-step wizard forms, email notifications, remote post handlers, file uploads, signature capture, and comprehensive submission management.

Drupal and the Webform module strives to be fully accessible to all users and site builders, with assistive technologies including screen readers and keyboard access fully supported.

Features

  • Drag-and-drop form builder with intuitive UI for creating and managing form elements
  • 80+ form element types including basic HTML, advanced HTML5, file uploads, composite elements, and custom widgets
  • Multi-step wizard forms with customizable progress bar and draft saving
  • Conditional logic using Drupal's States API for show/hide, required/optional, and enable/disable
  • Email handler for sending HTML emails with file attachments and customizable templates
  • Remote post handler for posting submission data to external APIs and services
  • Comprehensive submission management with viewing, editing, exporting, and purging
  • Export submissions to CSV, JSON, YAML, or HTML table formats
  • Reusable predefined options for select menus, checkboxes, and radio buttons
  • Access controls and permissions for form creation, submission viewing, and administration
  • Token support for dynamic content in messages, emails, and confirmations
  • Custom CSS and JavaScript per webform
  • Ajax support for form submission without page reload
  • Form scheduling with open/close dates
  • Submission limits per user or total submissions
  • Draft saving and autofill from previous submissions
  • Block and node integration for embedding forms
  • Extensive template system for customizing form appearance
  • Drush commands for automation and batch operations
  • Full internationalization and translation support

Use Cases

Contact Form

Create a basic contact form with name, email, subject, and message fields. Configure an email handler to send notifications to site administrators and a confirmation email to the submitter.

Survey/Questionnaire

Build multi-page surveys with Likert scales, rating elements, and conditional logic. Use the preview feature before submission and export results to CSV for analysis.

Job Application Form

Create a comprehensive job application with file uploads for resumes and cover letters. Use composite elements for contact information and entity reference for job position selection.

Event Registration

Build event registration forms with submission limits per event. Use the webform_node module to attach forms to event content types and track registrations.

Multi-Step Wizard Form

Create complex forms broken into logical steps using wizard pages. Enable draft saving so users can complete forms over multiple sessions.

CRM Integration

Use the Remote Post handler to submit form data to external CRM systems like Salesforce or HubSpot. Map form fields to API parameters.

Feedback Collection

Embed feedback forms throughout the site using blocks. Use conditional logic to show different questions based on user responses.

Order/Request Forms

Create forms with computed fields for totals, signature capture for agreements, and file attachments for supporting documents.

Tips

  • Use the 'Test' tab on any webform to quickly generate test submissions with sample data
  • Enable 'Details save' in advanced settings to remember the open/close state of configuration sections
  • Use YAML source editing for bulk updates to element labels, descriptions, or properties
  • Duplicate existing webforms or templates to quickly create similar forms
  • Configure default handler settings globally to reduce per-form configuration
  • Use computed elements with Twig to calculate values based on other form inputs
  • Enable Ajax submission for a smoother user experience without page reloads
  • Use the webform block to embed forms in sidebars or other regions
  • Create reusable option sets for commonly used select/checkbox options
  • Use conditional logic to create dynamic forms that adapt to user input
  • Enable submission logging for detailed audit trails of form activity
  • Use the Remote Post handler to integrate with external APIs and services
  • Configure Views integration for advanced custom submission reports

Technical Details

Admin Pages 14
Webforms /admin/structure/webform

Main webform management page listing all webforms with options to create, edit, delete, and manage submissions.

Webforms: Forms configuration /admin/structure/webform/config

Configure default settings for all webforms including page settings, form behaviors, and display options.

Webforms: Elements configuration /admin/structure/webform/config/elements

Configure default settings for form elements including allowed tags, CSS classes, and default behaviors.

Webforms: Submissions configuration /admin/structure/webform/config/submissions

Configure default settings for submission handling, limits, drafts, and purging.

Webforms: Handlers configuration /admin/structure/webform/config/handlers

Configure email defaults and manage which handlers are available in the form builder.

Webforms: Exporters configuration /admin/structure/webform/config/exporters

Configure default export settings for submission downloads.

Webforms: Libraries configuration /admin/structure/webform/config/libraries

Manage external JavaScript and CSS libraries used by the Webform module.

Webforms: Advanced configuration /admin/structure/webform/config/advanced

Configure advanced settings including UI options, batch processing, and requirements checking.

Webforms: Options /admin/structure/webform/options/manage

Manage reusable predefined options for select menus, checkboxes, and radio buttons.

Webforms: Submissions /admin/structure/webform/submissions/manage

View and manage all webform submissions across all webforms.

Webforms: Help /admin/structure/webform/help

Access help documentation, videos, and resources for the Webform module.

Webform plugins: Elements /admin/reports/webform-plugins/elements

View all available webform element plugins with their properties and settings.

Webform plugins: Handlers /admin/reports/webform-plugins/handlers

View all available webform handler plugins for processing submissions.

Webform plugins: Exporters /admin/reports/webform-plugins/exporters

View all available webform exporter plugins for downloading submissions.

Permissions 24
Administer webforms

Allows administration of global YAML configuration and options. Restricted access.

Administer webform submissions

Allows accessing, updating, and deleting all webform submissions. Restricted access with security implications.

Administer webform element access

Restrict webform element access to certain roles and users.

Administer webform overview

Filter webforms and perform bulk actions on overview page.

Access the webform overview page

Get an overview of all webforms.

Access the webform help page

Allows users to view the Webform module's help page.

Access the webform user submission page

Allows a user to view their submissions via 'Submissions' tab on their profile page.

Create webforms

Allows creation of new webforms.

Edit any webform

Allows managing any webform and its results. Restricted access.

Edit own webform

Allows managing of webform created by the user and its results.

Delete any webform

Allows deleting any webform. Restricted access.

Delete own webform

Allows deleting webforms created by the user.

Edit webform source code

Editing webform source code allows users to alter and possibly break a webform's render array. Restricted access.

Edit webform Twig templates

Editing inline Twig template allows users to access any data exposed by Twig functions. Restricted access.

Edit CSS/JS webform assets

Allows administrators to attach custom CSS and JavaScript to a webform. Restricted access.

Edit webform variants

Allows administrators to create variations of a webform. Restricted access.

Access own webform configuration

Allows users and applications to access a webform's configuration created by the user.

Access any webform configuration

Allows users and applications to access any webform's configuration.

View any webform submission

Allows viewing all submissions.

View own webform submission

Allows viewing own submissions for all webforms.

Edit any webform submission

Allows updating all submissions.

Edit own webform submission

Allows updating own submissions for all webforms.

Delete any webform submission

Allows deleting all submissions.

Delete own webform submission

Allows deleting own submissions for all webforms.

Hooks 24
hook_webform_element_info_alter

Alter the information provided in WebformElement annotation.

hook_webform_handler_info_alter

Alter the information provided in WebformHandler annotation.

hook_webform_variant_info_alter

Alter the information provided in WebformVariant annotation.

hook_webform_element_default_properties_alter

Alter a webform element's default properties.

hook_webform_element_translatable_properties_alter

Alter a webform element's translatable properties.

hook_webform_element_configuration_form_alter

Alter the element configuration form in the form builder.

hook_webform_element_alter

Alter webform elements during form rendering.

hook_webform_element_ELEMENT_TYPE_alter

Alter webform elements of a specific type during form rendering.

hook_webform_element_access

Check and set an element's #access property.

hook_webform_options_alter

Alter webform options.

hook_webform_options_WEBFORM_OPTIONS_ID_alter

Alter webform options by options ID.

hook_webform_submission_form_alter

Alter the webform submission form before rendering.

hook_webform_admin_third_party_settings_form_alter

Alter webform admin third party settings form.

hook_webform_third_party_settings_form_alter

Alter webform third party settings form.

hook_webform_handler_invoke_alter

Act on a webform handler when a method is invoked.

hook_webform_submissions_pre_purge

Respond before webform submissions are purged.

hook_webform_submissions_post_purge

Respond after webform submissions are purged.

hook_webform_access_rules

Supply additional access rules for webforms.

hook_webform_access_rules_alter

Alter list of access rules for webforms.

hook_webform_libraries_info

Return information about external webform libraries.

hook_webform_libraries_info_alter

Alter the webform module's libraries information.

hook_webform_help_info

Collect extra webform help from modules.

hook_webform_element_input_masks

Return information about input masks for text elements.

hook_webform_submission_query_access_alter

Alter webform submission query access.

Drush Commands 13
drush webform:export [webform_id]

Export webform submissions to a file

drush webform:import [webform_id] [file]

Import webform submissions from a CSV file

drush webform:purge [webform_id]

Purge webform submissions

drush webform:generate [webform_id]

Generate test submissions for a webform

drush webform:tidy [module]

Tidy webform YAML configuration files

drush webform:libraries:status

Display the status of third-party libraries required by webform

drush webform:libraries:download

Download third-party libraries required by webform

drush webform:libraries:remove

Remove downloaded third-party libraries

drush webform:libraries:composer

Generate composer.json for webform libraries

drush webform:repair

Repair webform configuration and settings

drush webform:remove:orphans

Remove orphaned submissions where the webform was deleted

drush webform:composer:update

Update webform's composer.json with library versions

drush webform:docs

Generate HTML documentation for webform

Troubleshooting 8
Form elements not saving

Check that the element key is unique and does not conflict with reserved words. Run drush webform:repair to fix configuration issues.

Emails not sending

Verify email handler configuration, check the default from address, and ensure your mail system is properly configured. Enable email debugging in handler settings.

Ajax not working

Check for JavaScript errors in browser console. Ensure Ajax is enabled in form settings and that there are no conflicting JavaScript libraries.

File uploads failing

Check file size limits in webform element settings and PHP configuration. Verify the upload directory has proper write permissions.

Conditional logic not working

Verify state conditions are properly configured. Note that some states may not work on all element types. Test in a clean browser cache.

Third-party libraries missing

Run drush webform:libraries:download to install required libraries, or enable CDN usage in configuration.

Submissions not appearing

Check form settings to ensure submission storage is enabled. Verify user has permission to view submissions.

Token replacement not working

Ensure the Token module is installed. Check token syntax and that the token is available in the current context.

Security Notes 10
  • Grant 'Administer webform' permission only to trusted administrators as it provides access to global configuration
  • The 'Edit webform source' permission allows users to alter render arrays and should be restricted
  • The 'Edit webform Twig' permission provides access to Twig functions and should be given to trusted users only
  • The 'Edit CSS/JS assets' permission allows custom code injection and should be restricted
  • File upload elements should be configured with appropriate file type restrictions and size limits
  • Enable CAPTCHA or other spam protection on public-facing forms
  • Use the confidential form setting to restrict access to authenticated users only
  • Consider disabling IP tracking for privacy-sensitive forms
  • Review handler configurations to ensure sensitive data is not exposed in emails or remote posts
  • Use access controls on individual webforms to restrict who can view, edit, or delete submissions