I want to update an field in hook_entity_insert()
. The following code doesn't work.
$entity->field_range->value = 'test';
$entity->save();
I also tried loading from node object, but still it doesn't work.
$node = \Drupal::entityManager()->getStorage('node')->load($entity->id());
$node->set('field_range', 'test');
$node->save();
After inserting the node only I will get the text "test" dynamically and it won't work in hook_entity_presave()
.
Any help on how to update an field on hook_entity_insert will be nice. Thanks in advance.