public function EntityForm::setEntity in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::setEntity()
- 9 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::setEntity()
Sets the form entity.
Sets the form entity which will be used for populating form element defaults. Usually, the form entity gets updated by \Drupal\Core\Entity\EntityFormInterface::submit(), however this may be used to completely exchange the form entity, e.g. when preparing the rebuild of a multi-step form.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.
Return value
$this
Overrides EntityFormInterface::setEntity
1 call to EntityForm::setEntity()
- DefaultsEntityForm::buildEntity in core/
modules/ layout_builder/ src/ Form/ DefaultsEntityForm.php - Builds an updated entity object based upon the submitted form values.
File
- core/
lib/ Drupal/ Core/ Entity/ EntityForm.php, line 345
Class
- EntityForm
- Base class for entity forms.
Namespace
Drupal\Core\EntityCode
public function setEntity(EntityInterface $entity) {
$this->entity = $entity;
return $this;
}