Module Development

Concept: Form Controllers and the Form Life Cycle for Drupal 8, 9, and 10

The life cycle of a Drupal form, from initial request to final processing, involves multiple stages. This tutorial outlines these stages and the role of form controllers, which contain custom form handling logic.

In this tutorial, we'll:

  • Define the role of a form controller.
  • List the phases of form processing in Drupal and how to add custom logic to each.
  • See how form controllers relate to routes for displaying full-page forms.

By the end of this tutorial, you should be able to explain the role of a form controller and how to get started creating a new one.

Drupal Module Developer Guide