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