Retrieving and displaying forms

Created on 25 January 2017, over 8 years ago
Updated 3 April 2025, about 1 month ago

The following link:

https://api.drupal.org/api/drupal/core%21core.api.php/group/form_api/8.2.x

says the following in part.

Retrieving and displaying forms

\Drupal::formBuilder()->getForm() should be used to handle retrieving, processing, and displaying a rendered HTML form. Given the ExampleForm defined above, \Drupal::formBuilder()->getForm('Drupal\mymodule\Form\ExampleForm') would return the rendered HTML of the form defined by ExampleForm::buildForm(), or call the validateForm() and submitForm(), methods depending on the current processing state.

I used this pattern and found that formBuilder->getForm returns a complex data structure that I believe is known as a Form Array. I believe this documentation needs to be updated as a result. The following page seems to agree with my results:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21Fo...

I need to be able to place a form in an arbitrary place in a Block. I was hoping formBuilder->getForm would allow this -- but this does not seem to be the case.

πŸ› Bug report
Status

Closed: works as designed

Component

Correction/Clarification

Created by

πŸ‡ΊπŸ‡ΈUnited States Greg Sims

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    I don't see anything to do here. @eojthebrave, has said that the docs are correct and went further to provide advice.

    Therefore, closing this.

Production build 0.71.5 2024