Release Day: Drupal 8 Form API


Introduced way back in Drupal 4.7 and evolving ever since, the Form API is essential for any module developer to master. Forms are one of the primary means through which users interact with a web application. And the Form API is how Drupal module developers create, update, and modify forms.

For many developers implementations of hook_form_api() are the first foray into writing custom modules. No matter where you are on your journey to mastering Drupal module development you'll benefit from understanding the ins-and-outs of the Form API.

In this first set of tutorials on the Form API, we'll talk about what exactly the Form API is and the benefits it has over hard-coded HTML forms, including a detailed look at the life cycle of a form and the various points at which developers can jump in and customize things. We'll discuss the overlap between the Form API and the Render API, look at how to map a route to a form controller, and how form controllers can build, validate, and process submitted data for, forms.

We'll also look at the venerable hook_form_api(), how to implement it, and some examples of not changing how forms look but also how they are validated and processed.

Here's the full list of tutorials we're releasing today:

In the future, we'll be adding additional tutorials on:

  • Submitting forms via AJAX
  • Handling file uploads
  • and, creating multi-step wizards with the Form API

Let us know if you've got any burning questions about Drupal's Form API.


When a user submits a form the request is made to the same URL that the form was displayed on, Drupal notices the incoming HTTP POST data in the request and this time instead of building the form and displaying it as HTML, it builds the form and then proceeds to call the applicable validation and submission handlers.

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code class> <ul type> <ol start type> <li> <dl> <dt> <dd><h3 id> <p>
  • Lines and paragraphs break automatically.

About us

Drupalize.Me is the best resource for learning Drupal online. We have an extensive library covering multiple versions of Drupal and we are the most accurate and up-to-date Drupal resource. Learn more