function FormBuilderInterface::getForm
Same name in other branches
- 9 core/lib/Drupal/Core/Form/FormBuilderInterface.php \Drupal\Core\Form\FormBuilderInterface::getForm()
- 8.9.x core/lib/Drupal/Core/Form/FormBuilderInterface.php \Drupal\Core\Form\FormBuilderInterface::getForm()
- 11.x core/lib/Drupal/Core/Form/FormBuilderInterface.php \Drupal\Core\Form\FormBuilderInterface::getForm()
Gets a renderable form array.
This function should be used instead of self::buildForm() when $form_state is not needed (i.e., when initially rendering the form) and is often used as a menu callback.
@todo Uncomment new method parameters before drupal:11.0.0.
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.
phpcs:disable Drupal.Commenting
mixed ...$args: Any additional arguments are passed on to the functions called by \Drupal::formBuilder()->getForm(), including the unique form constructor function. For example, the node_edit form requires that a node object is passed in here when it is called. These are available to implementations of hook_form_alter() and hook_form_FORM_ID_alter() as the array $form_state->getBuildInfo()['args']. phpcs:enable
Return value
array The form array.
See also
https://www.drupal.org/project/drupal/issues/3354672
\Drupal\Core\Form\FormBuilderInterface::buildForm()
File
-
core/
lib/ Drupal/ Core/ Form/ FormBuilderInterface.php, line 67
Class
- FormBuilderInterface
- Provides an interface for form building and processing.
Namespace
Drupal\Core\FormCode
public function getForm($form_arg);
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.