There's an ongoing discussion about how there should be CRUD hooks on bundle events, hook_entity_bundle_[create/load/update/delete/etc] (currently in the context of Drupal 8).

In the mean time, in Drupal 7, what's the closest thing we have to a hook_entity_bundle_create? To put it another way, how best to define a function that will be called every time an entity bundle is created, where the function can access data about that bundle?

The above link mentions the hook_field_attach hooks (the Field Attach API), but it's not clear which if any of these hooks will be called reliably on bundle editting.

It's be great to clearly get down what the current equivalent of bundle CRUD hooks are.

2 Answers 2


So here's the best I can find so far. It's not great.

  • Create: There's hook_field_attach_create_bundle, but it doesn't automatically get called any time a bundle is created. Seems that every module for every entity with bundles has to call field_attach_create_bundle($entity_type_name, $bundle_type_name); every time a bundle is going to be created/saved, else the hook doesn't know about it. It seems not to do anything except call the hooks - I've seen modules that forget to add this line.
  • Read: I can't find an equivalent here (no big deal I guess as it's not clear what 'reading' a bundle would mean - accessing info on it?)
  • Update: The closest I can find is hook_field_attach_rename_bundle. Not great.
  • Delete: There's hook_field_attach_delete_bundle. Like ..._create, it needs to be called in the code, so some modules' entities might not call it. But it appears that field_attach_delete_bundle() actually handles the deletion of field data, so it's less likely to be forgotten or overlooked.

The Drupal 8 change notice covers these points nicely.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.