I've created a Custom Field (let's call it 'Reference') whose value requires the Entity Id.
To accomplish that I modify the Field value in the postSave method, like this:
if (!$update) {
$this->get('value')
->setValue($this->getCalculatedReferenciaValue());
}
public function getCalculatedReferenciaValue() {
//...
$entity = $this->getEntity();
$id = $entity->id();
$year = date("Y", $date);
// default format: 'SWAN%s%08dIMOV'
$format = $this->getSetting('format');
return sprintf($format, $year, $id);
}
Then, in pathauto, I use that custom created field, as a token, to generate the path.
However, for some reason, when creating a node, my custom field still has the default value.
If I then edit and save the node, the custom field (and the auto path) is updated correctly.
Q: Is there a way to update the field value so that it becomes available when generating the autopath for the first time?