function FieldableEntityInterface::set

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/FieldableEntityInterface.php \Drupal\Core\Entity\FieldableEntityInterface::set()
  2. 8.9.x core/lib/Drupal/Core/Entity/FieldableEntityInterface.php \Drupal\Core\Entity\FieldableEntityInterface::set()
  3. 11.x core/lib/Drupal/Core/Entity/FieldableEntityInterface.php \Drupal\Core\Entity\FieldableEntityInterface::set()

Sets a field value.

Parameters

string $field_name: The name of the field to set; e.g., 'title' or 'name'.

mixed $value: The value to set, or NULL to unset the field.

bool $notify: (optional) Whether to notify the entity of the change. Defaults to TRUE. If the update stems from the entity, set it to FALSE to avoid being notified again.

Return value

$this

Throws

\InvalidArgumentException If the specified field does not exist.

File

core/lib/Drupal/Core/Entity/FieldableEntityInterface.php, line 170

Class

FieldableEntityInterface
Interface for entities having fields.

Namespace

Drupal\Core\Entity

Code

public function set($field_name, $value, $notify = TRUE);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.