function FormBuilderInterface::buildForm
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Form/FormBuilderInterface.php \Drupal\Core\Form\FormBuilderInterface::buildForm()
- 10 core/lib/Drupal/Core/Form/FormBuilderInterface.php \Drupal\Core\Form\FormBuilderInterface::buildForm()
- 11.x 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:
- The name of a class that implements \Drupal\Core\Form\FormInterface.
- An instance of a class that implements \Drupal\Core\Form\FormInterface.
\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\FormCode
public function buildForm($form_arg, FormStateInterface &$form_state);
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.