W3cubDocs

/Drupal 8

public function EntityForm::setEntity

public EntityForm::setEntity(EntityInterface $entity)

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

File

core/lib/Drupal/Core/Entity/EntityForm.php, line 343

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

Code

public function setEntity(EntityInterface $entity) {
  $this->entity = $entity;
  return $this;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityForm.php/function/EntityForm::setEntity/8.1.x