Drupal’s most potent and versatile form builder and submission manager is the Webform module. It enables site builders to quickly and simply create complicated forms. It allows you to customize it to meet your needs and comes with a set of default settings.

Visit this wonderful blog: Drupal 9 Webform Module. A succinct tutorial to assist you in setting up the Drupal 9 or 10 website’s Webform module. You can easily understand the fundamentals thanks to this. 

There are so many fascinating features included with the Webform module! Permit me to give a brief rundown of some of the standout attributes and capabilities that elevate this module to the top of the Drupal hierarchy.

Modifying Forms And Elements

The hooks associated with each form, element, and their associated settings can be used to change them. You can use the hooks listed below, and there are more in the webform.api.php file:

The form hooks include hook_webform_submission_form_alter(), Make changes prior to the rendering of a webform submission form.

Webform elements can be altered using element hooks, specifically hook_webform_element_alter().

Webform options can be altered through option hooks, such as hook_webform_options_alter().

Hooks for handlers ◦ hook_webform_handler_invoke_alter() When a method is called, take action on a webform handler.

additional hooks

For example, hook_webform_access_rules_alter().

A different set of access rules that need to be controlled individually for each webform.

YAML Source Configuration

YAML Form was the original name of the Webform module, which let users create forms using YAML markup. The Drupal 8 Webform module was once the YAML Form module with a user interface.

YAML offers a straightforward markup language for creating and editing web form elements in bulk.

Developers can use YAML markup on the (View) Source page to modify a web form’s render array. The (View) Source page allows developers to hand-code web forms to quickly change a web form’s labels, cut and paste multiple elements, rearrange elements, and add custom properties and markup to elements.

Here is an illustration of a Contact form along with the YAML source code that goes with it:


Source: SpecBee


Source: SpecBee

Conditional fields Logic

You can include conditional logic in your form’s elements using Webform. Let’s look at a little example where we have to handle some elements’ visibility conditionally based on the value of another element in the form.

This is an example of a two-step form with the options “Email” and “Mobile Number” in STEP 1 (Radios element). “Email” and “Mobile Number” are the two elements in STEP 2 (Fieldset).

Source: SpecBee

Source: SpecBee

In the example above, if the “Email” option is selected in Step 1, I would like to display the “Email” field; if the “Mobile Number” option is selected in Step 1, I would like to display the “Mobile Number” field.

In order to do that, edit the “Email” field, select the “Conditions” tab, select “Visible” for the “State,” and enter “STEP 1 [Radios] value is email” for the “Trigger/Value.” Likewise, add conditional logic to your “Mobile Number” field by following the same steps and setting the “Trigger/Value” to “STEP 1 [Radios] value is mobile_number.” This is the Webform’s final appearance:

Source: SpecBee

Source: SpecBee

Source: SpecBee

Custom options properties

You can give your from elements custom option properties with Webform.

Consider a situation where you would like to manage a radio element’s options conditionally on the value of another element on the form. How would you go about doing that?

Unfortunately, I was unable to resolve it using the UI’s Conditional Logic settings. However, you can use the YAML code to write the necessary conditional logic targeting your options within the element in order to set “custom options properties” to your element.

Here’s an example: there are two radio elements, and the options in the second element should become visible or invisible depending on my selection in the first element.

Source: Specbee

Web-Front Module For Drupal

“Option 1” and “Option 2” ought to be visible from the second element if “Type A” is selected. Likewise, selecting “Type B” ought to highlight “Options 3 and 4”.

This can be accomplished by editing the second element, selecting the “Advanced” tab, swiping down to the “Options (custom) properties” sections, and creating the required YAML logic.

Web-Front Module For Drupal

Source: SpecBee

Web-Front Module For DrupalSource: SpecBee

Web-Front Module For Drupal

Source: SpecBee

Webform submission email handlers

handlers of emails

Email handlers send an email containing a webform submission. Go to the “Emails/Handlers” tab under “Settings” to add email handlers to your webformNext, choose “Add Email / Add handler” from the drop-down list.

Add the “Title” and configure the “Send to” and “Send from” details on the “General” tab, as indicated in the image below. As needed, add the messages “Subject” and “Body,” then save the configuration form. 

That’s it for now. Every time the form is submitted, your handler is terminated.

Web-Front Module For Drupal

Web-Front Module For Drupal

Additionally, you can add conditional email handlers to your webform, which will cause various email handlers to fire depending on the values of particular form elements.

As an illustration, let’s look at a “Select” element with the values “Type 1” and “Type 2.” Trigger the “Email – Type 1” handler with the “To” address set to in the event that a user submits a “Type 1” request, “user1@gmail.com”. Trigger the “Email – Type 2” handler with the “To” address set to “user2@gmail.com” if the user submits a “Type 2” request.

Create a handler called “Email – Type 1” in order to add conditional logic to your email handler. Change the “To” address to “user1@mail.com,” select “Select Type [Select] value is type_1,” go to the “Conditions” Tab, and select “Visible” for the “State” and “Trigger/Value.” 

Make a second handler with the same name, “Email – Type 2.” Change the “To” address to “user2@gmail.com,” select “Select Type [Select] value is type_2,” go to the “Conditions” Tab, and select “Visible” for the “State” and “Trigger/Value.”

Email handlers on a schedule

It adds support for scheduling emails to the email handler of the Webform module. Enable the “Webform Scheduled Email Handler” sub-module in order to utilize this feature. 

Click the “Add handler” button to arrange for the form submissions to be sent by email. Here, choose the handler for “Scheduled Email.”

When comparing the “Scheduled Email” handler to the standard “Email handler,” there is only one additional configuration setting. And that is to go to the General settings tab and add a Schedule email date.

Your email will be sent when the next cron is run if you have set the date to activate your handler! 

Web-Front Module For Drupal


Creating PDF Copies of Webform Submissions

We can download and export webform submissions as PDF documents using the webform module. It also allows you to modify the PDF documents’ templates and CSS and send these files as email attachments.

How can we make this function? In order to download and export the PDF documents, you must first enable the Webform Entity Print (PDF) and Webform Entity Print (PDF) Attachment submodules (to send these PDF documents as email attachments).

Please take note that printing any Drupal entity (Drupal 7, 9, and 10) or View (Drupal 9 and 10 only) to PDF requires the installation of the Entity Print module.

Download a single submission’s PDF.

Go to the results page of your webforms, select the submission you wish to download, and then scroll down to select “Download PDF.”

Export several webform submissions as a zip file containing a PDP document. 

Go to the Download exports tab on your webforms results page, select “PDF document” as the export format, and click “Download.” 

Web-Front Module For Drupal

All of your webform submissions will be sent to you in a single *.tar.gz or *.zip file as a PDF.

Customize the PDF documents’ templates and CSS.

Go to the ‘Entity print’ settings section by scrolling down from the general settings tab of your webforms (/admin/structure/webform/manage/{your-webform-name}/settings).

Web-Front Module For Drupal

Add the required CSS to be displayed in your PDF along with the header and footer template details (it supports tokens). 

Add some CSS and a default header and footer to personalize your PDF.

Include these PDF files in your emails.

To begin, add a PDF element to your webform. Include information about the PDF element, such as the file name, view mode, and title, and save it.

Your results column now has the PDF element (please note: we are not adding it to our form). You will be taken to your PDF document when you click on it.

Attaching it to emails is the next step. Navigate to Settings > Email/Handlers for that.

Web-Front Module For Drupal

When editing an email handler, make sure to select the PDF element, turn on “Include files as attachments,” and then save the handler.

The PDF and information about submitting the webform will be attached to your email the next time you submit it.


For web developers, our in-depth guide on the Web-Front Module for Drupal 10 in 2024 offers crucial perspectives and useful tactics. Through proficiency with this module, developers can unlock new possibilities and improve the functionality and efficiency of Drupal-based web projects, which will guarantee success in the constantly changing web development landscape.

We hope that this tutorial has helped you with Drupal Core with Composer. Additionally, Appic Softwares is a company you should check out if you’re wanting to hire Drupal developers on a devoted basis.

You can employ our team of knowledgeable Drupal developers to handle your software.

So, what are you waiting for?

Hire them now!

This blog is inspired by: https://www.specbee.com/blogs/webform-module-drupal-10