Advertising sustains the DA. Ads are hidden for members. Join today

Entity List Field Developer Documentation

Last updated on
18 June 2025

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

Extending the class

If you want to use your own class for the Entity List field formatter, write a module with a class that extends EntityListFieldList...

class MyClass extends EntityListFieldList {}

...and configure your field instance so it uses your class. You’ll see the List class setting at the bottom of the settings form when you create an Entity List field.

Registering your class

For compatibility with entity_lister, you must also add your class to the allowed classes like so...

EntityLister::addAllowedClass('MyClass');

A good place to add that line of code is in your module's hook_enable implementation. You should call removeAllowedClass in your hook_disable to clean up the variable set in addAllowedClass. See the addAllowedClass and removeAllowedClass methods in the EntityLister class.

Help improve this page

Page status: Not set

You can: