hook_entity_field_values_init(\Drupal\Core\Entity\FieldableEntityInterface $entity)
Acts when initializing a fieldable entity object.
This hook runs after a new entity object or a new entity translation object has just been instantiated. It can be used to set initial values, e.g. to provide defaults.
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity object.
hook_ENTITY_TYPE_field_values_init()
function hook_entity_field_values_init(\Drupal\Core\Entity\FieldableEntityInterface $entity) { if ($entity instanceof \Drupal\Core\Entity\ContentEntityInterface && !$entity->foo->value) { $entity->foo->value = 'some_initial_value'; } }
© 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!entity.api.php/function/hook_entity_field_values_init/8.1.x