class EntityFormBuilder
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityFormBuilder.php \Drupal\Core\Entity\EntityFormBuilder
- 8.9.x core/lib/Drupal/Core/Entity/EntityFormBuilder.php \Drupal\Core\Entity\EntityFormBuilder
- 10 core/lib/Drupal/Core/Entity/EntityFormBuilder.php \Drupal\Core\Entity\EntityFormBuilder
Builds entity forms.
Hierarchy
- class \Drupal\Core\Entity\EntityFormBuilder implements \Drupal\Core\Entity\EntityFormBuilderInterface
Expanded class hierarchy of EntityFormBuilder
1 file declares its use of EntityFormBuilder
- EntityFormBuilderTest.php in core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityFormBuilderTest.php
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityFormBuilder.php, line 11
Namespace
Drupal\Core\EntityView source
class EntityFormBuilder implements EntityFormBuilderInterface {
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
/**
* Constructs a new EntityFormBuilder.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, FormBuilderInterface $form_builder) {
$this->entityTypeManager = $entity_type_manager;
$this->formBuilder = $form_builder;
}
/**
* {@inheritdoc}
*/
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);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
EntityFormBuilder::$entityTypeManager | protected | property | The entity type manager service. | |
EntityFormBuilder::$formBuilder | protected | property | The form builder. | |
EntityFormBuilder::getForm | public | function | Gets the built and processed entity form for the given entity. | Overrides EntityFormBuilderInterface::getForm |
EntityFormBuilder::__construct | public | function | Constructs a new EntityFormBuilder. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.