Get form ID on hook_entity_presave() I want to process some details before saving the node in Drupal 8. How will I get the form ID of the submitted form?

function mymodule_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  $entity-&gt;getEntityType()-&gt;id() // this only prints "node"
}


Is there any other workaround?
hook_entity_presave() doesn't get the form ID, and this makes sense: An entity could be programmatically saved from a module or a Drush plugin without showing to the user a form to edit/create the entity.

Since you just want to know if the entity is being edited or created:


You don't need to know the form ID
You can use hook_entity_presave() or hook_ENTITY_TYPE_presave() with code similar to the following one

function mymodule_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity-&gt;isNew()) {
    // The entity is being created.
  }
}



As side note, $entity-&gt;getEntityType()-&gt;id() returns 'node' as expected: You are asking to the entity object its entity type, and for nodes that is clearly 'node'.