Forms in Drupal 8

Amber Himes Matz
Drupal is built around forms. Adding content, creating users, and building views all happen via filling out and submitting forms. Forms are an essential part of any Content Management System, and knowing how to utilize the classes and interfaces provided in Drupal 8 for form building will be a vital skill for any module developer.
In this session, we'll walk through the complete Form API workflow — including form building, validation, and submission — in Drupal 8 using object-oriented code practices. You'll learn how to build all types of forms in Drupal 8.
After this session you will be able to:
  • Build, validate, and submit a form
  • Save time writing form code by extending base classes
  • Code to the right Interface (and learn what an Interface is!)
  • Identify the new form input elements in Drupal 8 core
  • Build a settings or configuration form
  • Understand what changed in the Form API from D7 to D8

This session assumes that you have some familiarity with PHP. You don't need to be an expert by any means, but you should recognize basic PHP syntax, like arrays. You don't need to know object-oriented PHP either. Forms in Drupal 8 are a great way to learn about the object-oriented architectural changes in Drupal 8 and how to work within this powerful new framework. If you have built a form in Drupal 7, this is a great place to learn about the changes in the Form API in Drupal 8. You will gain enough knowledge to port your Drupal 7 forms to work in Drupal 8.

Why should you listen to me? I am a trainer for Drupalize.Me at Lullabot with a background in Drupal and PHP development. I enjoy making technical subjects accessible to all skill levels. I have been hacking away at the web for over 14 years. My presentations and examples are peer reviewed by some seriously smart folks at Lullabot and Drupalize.Me. Join me and learn to kick ass with forms in Drupal 8.

Session Track

Coding and Development

Experience Level


Drupal Version