How to Build Custom Forms in Drupal 8?

How to Build Custom Forms in Drupal 8?

Introduction: Building Complex Forms in Drupal 8

This Tutorial will show how to build custom Forms in Drupal 8 with Fields, Content Types, Webform, & the core ContactForm module that all collect queried information from users. Using Content Types with CCK Fields, Webforms, & Contact Forms can be combined as required to build data collection solutions for websites, i.e. address, email, & phone numbers. The Contact Form & CCK modules are part of the default Drupal 8 installation but users will be required to install the Webform module which offers more advanced field customization options. Before getting started, have hosting that supposed Drupal such as these Drupal hosting services.

Step One:
Install the Contact, CCK, & Webform Modules

Start: Navigate to the Modules section of Drupal 8 administration. Confirm that the Contact Form module and the Field/Field UI modules are all enabled or enable & save the settings. Next: Download & install the Webform module at admin/modules/install using the zip/gzip file.

Configuration: The Webform Module has three collections of sub-modules which must all be enabled in order to use the different features. Enable all of the options shown below. How to Build Custom Forms in Drupal 8?


  • (x) Webform – Enables the creation of webforms and questionnaires.
  • (x) Webform Access – Provides webform access controls for webform nodes.
  • (x) Webform Bootstrap Helps support Webform to Bootstrap integration.
  • (o) Webform Devel – Provides development tools for the Webform module.
  • (x) Webform Image Select Provides a webform element for a selecting an image.
  • (x) Webform Node – Provides a Webform content type which allows webforms to be integrated into a website as nodes.
  • (x) Webform Scheduled Email Handler Extends the Webform email handler to allow emails to be scheduled.
  • (x) Webform Templates – Provides starter templates that can be used to create new webforms.
  • (x) Webform UI – Provides a user interface for building and maintaining webforms.

Configuration: Enable all of the module choices except for Webform Devel and then save the module settings. Optional: Enable the additional example modules for Webform. How to Build Custom Forms in Drupal 8?


  • (x) Webform Element Example – Provides an example that shows how to create a Webform element.
  • (x) Webform Example Composite – Provides an example that shows how to create a Webform composite.
  • (x) Webform Examples Provides examples of all webform elements and functionality which can used for demonstrating and testing advanced functionality or used as cut-n-paste code snippets for creating new webforms.
  • (x) Webform Examples Accessibility – Provides example webforms for reviewing and testing accessibility.
  • (x) Webform Handler Example – Provides an example of a webform handler.
  • (x) Webform Remote Post Example – Provides an example of a webform submission posted to a remote server.


  • (o) Webform Shortcuts – Provides keyboard shortcuts to create and save webform elements.

Configuration: Enable all of the example modules but leave the experimental module disabled. Finish: Save the module settings and use the sample Webform content as a guide for building complex forms in Drupal 8 on the basis of the provided templates for web publishing needs.

Step Two:
Configure the Site-Wide Contact Form

Start: The Drupal 8 Contact Form allows any user who browses a website to send a email to the site owner. The Contact Form can also be customized with Fields for data collection. Next: Navigate to admin/structure/contact & add a new Contact Form. How to Build Custom Forms in Drupal 8? Hint:Drupal 8 gives administrators the ability to create multiple contact forms, i.e. a site-wide form for anonymous users, business inquiry by a department, or special offer promotions. How to Build Custom Forms in Drupal 8? Configuration: Enter required values for the Label, Recipients (email addresses), Display Messages, & Redirect Path. Save the settings then use the path URL for menu links.

Step Three:
Build a Webform for Custom Form Requirements

Start: The Webform module for Drupal 8 is sponsored and includes video tutorial content with sample Form content to get started. Navigate to: admin/structure/webform How to Build Custom Forms in Drupal 8? Next: Click on the link to “Add New Webform” & enter a name in the pop-up screen. On the form build page, click on the link “Add Element” and choose the type of Field required in the pop-up. How to Build Custom Forms in Drupal 8? Finish: Add fields for customer address, phone number, & email or use text fields for more lengthy written responses from consumers on surveys. Link the Webform URL to menu GUIs.

Step Four:
Use CCK Fields & Nodes for Advanced Solutions

Start: Another way to build forms for users in Drupal 8 is to add custom Fields to Content Types, and then use the node create (node/add/***) form for registered users to submit data. Next: Navigate to admin/structure/types/add and add a new Content Type to the CMS. How to Build Custom Forms in Drupal 8? Next: Navigate to admin/structure/types and click on “Manage Fields” to build the custom form. Use fields for address, email, phone number, images, pdf files, text responses, or html text. Important: Make sure to set Permissions for User Roles on the content type used as a form at: admin/people/permissions so that users cannot view the response data that is collected. Finish: Use the node create page for the Content Type or embed the form in a Block for Panels pages. Drupal 8 Fields can also be integrated with Views for custom display pages.

Conclusion: Build Forms with Custom Fields in Drupal 8

Summary: The Contact Form is an essential part of any CMS website, while the Webform module for Drupal 8 is best for creating advanced custom forms with many different field values. Recommendation: Use custom Fields on D8 Content Types for Form solutions that require better Views integration or install the Webform Views Integration module for panel displays.

Drupal 8 Form Modules: Choose between the Contact Form, the Webform module, or using custom CCK Fields on a Content Type depending on the requirements for data collection.

How to Create a Custom Content Type for Drupal 8 with Fields

This Tutorial will show how to create a database application for Drupal using cu
4 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How To Set Up SSL/TLS (HTTPS) Encryption on Drupal

Drupal is an industry-leading, open-source Content Management System for develop
4 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use Amazon RDS with your WordPress Installation

The default instance which is set up while creating an EC2 server with complete
3 min read
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Start an Online Store on the WordPress Platform

It's an era of e-commerce and people always look for a better source to star
5 min read
Angela Olaru
Angela Olaru
Senior Writer & Hosting Expert provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top