Webform
webform
A comprehensive form builder and submission manager for Drupal that enables creation of webforms and questionnaires with extensive customization options.
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.
Install
composer require 'drupal/webform:^6.2'
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
Dependencies
Related Projects
Provides spam protection integration without CAPTCHAs
Integrates CAPTCHA challenges for spam protection
Provides honeypot spam protection integration
Enables client-side form validation
Enables PDF generation of submissions
Provides token replacement in messages and emails
Development tools integration
Advanced email sending with HTML and attachments
Custom submission views and reports
Translation management integration
File browser integration for HTML editor
Admin Pages
| Title | Path | Description |
|---|---|---|
| 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
| Permission | Description |
|---|---|
|
Allows administration of global YAML configuration and options. Restricted access. |
|
Allows accessing, updating, and deleting all webform submissions. Restricted access with security implications. |
|
Restrict webform element access to certain roles and users. |
|
Filter webforms and perform bulk actions on overview page. |
|
Get an overview of all webforms. |
|
Allows users to view the Webform module's help page. |
|
Allows a user to view their submissions via 'Submissions' tab on their profile page. |
|
Allows creation of new webforms. |
|
Allows managing any webform and its results. Restricted access. |
|
Allows managing of webform created by the user and its results. |
|
Allows deleting any webform. Restricted access. |
|
Allows deleting webforms created by the user. |
|
Editing webform source code allows users to alter and possibly break a webform's render array. Restricted access. |
|
Editing inline Twig template allows users to access any data exposed by Twig functions. Restricted access. |
|
Allows administrators to attach custom CSS and JavaScript to a webform. Restricted access. |
|
Allows administrators to create variations of a webform. Restricted access. |
|
Allows users and applications to access a webform's configuration created by the user. |
|
Allows users and applications to access any webform's configuration. |
|
Allows viewing all submissions. |
|
Allows viewing own submissions for all webforms. |
|
Allows updating all submissions. |
|
Allows updating own submissions for all webforms. |
|
Allows deleting all submissions. |
|
Allows deleting own submissions for all webforms. |
Hooks
| Hook | Description |
|---|---|
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
| Command | Description |
|---|---|
|
Export webform submissions to a file |
|
Import webform submissions from a CSV file |
|
Purge webform submissions |
|
Generate test submissions for a webform |
|
Tidy webform YAML configuration files |
|
Display the status of third-party libraries required by webform |
|
Download third-party libraries required by webform |
|
Remove downloaded third-party libraries |
|
Generate composer.json for webform libraries |
|
Repair webform configuration and settings |
|
Remove orphaned submissions where the webform was deleted |
|
Update webform's composer.json with library versions |
|
Generate HTML documentation for webform |
Troubleshooting
Check that the element key is unique and does not conflict with reserved words. Run drush webform:repair to fix configuration issues.
Verify email handler configuration, check the default from address, and ensure your mail system is properly configured. Enable email debugging in handler settings.
Check for JavaScript errors in browser console. Ensure Ajax is enabled in form settings and that there are no conflicting JavaScript libraries.
Check file size limits in webform element settings and PHP configuration. Verify the upload directory has proper write permissions.
Verify state conditions are properly configured. Note that some states may not work on all element types. Test in a clean browser cache.
Run drush webform:libraries:download to install required libraries, or enable CDN usage in configuration.
Check form settings to ensure submission storage is enabled. Verify user has permission to view submissions.
Ensure the Token module is installed. Check token syntax and that the token is available in the current context.
Security Notes
- 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