You are here

public function EntityFormBuilder::getForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityFormBuilder.php \Drupal\Core\Entity\EntityFormBuilder::getForm()
  2. 9 core/lib/Drupal/Core/Entity/EntityFormBuilder.php \Drupal\Core\Entity\EntityFormBuilder::getForm()

File

core/lib/Drupal/Core/Entity/EntityFormBuilder.php, line 43

Class

EntityFormBuilder
Builds entity forms.

Namespace

Drupal\Core\Entity

Code

public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []) {
  $form_object = $this->entityTypeManager
    ->getFormObject($entity
    ->getEntityTypeId(), $operation);
  $form_object
    ->setEntity($entity);
  $form_state = (new FormState())
    ->setFormState($form_state_additions);
  return $this->formBuilder
    ->buildForm($form_object, $form_state);
}