public FormBuilderInterface::buildForm($form_id, FormStateInterface &$form_state)
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_id: 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()
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_id, FormStateInterface &$form_state);
Please login to continue.