Skip to main content
added code
Source Link
Vagner
  • 2.5k
  • 15
  • 20

To change Entities fields its better use MODULE_ENTITY_presave() function (more info in docs).

In this case that you need change a node field use this function:

function hook_node_presave(Drupal\Core\Entity\EntityInterface $entity) {
  $entity->set('title', 'Updated title');
}

To change Entities fields its better use MODULE_ENTITY_presave() function (more info in docs).

In this case that you need change a node field use this function:

function hook_node_presave(Drupal\Core\Entity\EntityInterface $entity) {

}

To change Entities fields its better use MODULE_ENTITY_presave() function (more info in docs).

In this case that you need change a node field use this function:

function hook_node_presave(Drupal\Core\Entity\EntityInterface $entity) {
  $entity->set('title', 'Updated title');
}
Source Link
Vagner
  • 2.5k
  • 15
  • 20

To change Entities fields its better use MODULE_ENTITY_presave() function (more info in docs).

In this case that you need change a node field use this function:

function hook_node_presave(Drupal\Core\Entity\EntityInterface $entity) {

}