Retrieve and Display Forms for Drupal 8, Drupal 9, and Drupal 10

Last updated February 19, 2021
Module Development9.5.x/10.0.x

Forms can be displayed as the main content of a route or by using the form_builder service to retrieve and display a form directly. Which one you choose will depend on where on the page you want the form to appear.

In this tutorial we'll:

  • Go over the two different ways a form can be retrieved and displayed
  • Demonstrate how to display a form inside a custom block using the form_builder service

By the end of this tutorial you'll know how to retrieve a form and have it rendered anywhere on the page.