You are here

public function FormBuilderInterface::buildForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Form/FormBuilderInterface.php \Drupal\Core\Form\FormBuilderInterface::buildForm()
  2. 10 core/lib/Drupal/Core/Form/FormBuilderInterface.php \Drupal\Core\Form\FormBuilderInterface::buildForm()

Builds and processes a form for a given form ID.

The form may also be retrieved from the cache if the form was built in a previous page load. The form is then passed on for processing, validation, and submission if there is proper input.

Parameters

\Drupal\Core\Form\FormInterface|string $form_arg: The value must be one of the following:

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The rendered form. This function may also perform a redirect and hence may not return at all depending upon the $form_state flags that were set.

Throws

\Drupal\Core\Form\FormAjaxException Thrown when a form is triggered via an AJAX submission. It will be handled by \Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber.

\Drupal\Core\Form\EnforcedResponseException Thrown when a form builder returns a response directly, usually a \Symfony\Component\HttpFoundation\RedirectResponse. It will be handled by \Drupal\Core\EventSubscriber\EnforcedFormResponseSubscriber.

See also

self::redirectForm()

1 method overrides FormBuilderInterface::buildForm()
FormBuilder::buildForm in core/lib/Drupal/Core/Form/FormBuilder.php
Builds and processes a form for a given form ID.

File

core/lib/Drupal/Core/Form/FormBuilderInterface.php, line 92

Class

FormBuilderInterface
Provides an interface for form building and processing.

Namespace

Drupal\Core\Form

Code

public function buildForm($form_arg, FormStateInterface &$form_state);