I developed custom entities in the code, using entity references : A <- R -> C. Entity "R" contains references to "A" and "B".

I'd like to add a pseudo-field in entity "A", configurable in view display, that could render referencing entities (mean "R" entities referencing "A" with a given field "F").

Since I made my own classes for the entities, I'd really like to continue that way and prevent using hooks. I know I could achieve this with views, but it seems more logical, reusable, and quicker, to put it in entity code.

  1. Is there a way to add the display field to my entity without using hook_entity_extra_field_info() ? For example could I create my own FieldEntityManager ?

  2. Is EntityViewBuilder the right place to render the field with my own data ?

  3. In a more generic way, would it be possible to develop a custom field type "referencing_entities" that I could reuse in every referenced entities I have ? Would it be only a field formatter since I don't need to store anything ? Is it possible to access to the entity from the field to query referencing entities ?

  • I am looking for the same requirement i.e. having pseudo field with formatter drupal 8. Did you find your answer to this query? Oct 25, 2017 at 13:07
  • 1
    Add a computed field. Theres a core issue just rtbc that makes this easier and discusses some catches, I suggest looking at that.
    – Jonathan
    Nov 12, 2017 at 11:54

1 Answer 1


As time goes by there's Extra Field now.

Provides a plugin type for extra fields in entity view.

This module allows developers to add custom fields by simply providing a plugin. Site builders can use these fields in entity view modes as normally. Extra fields do not store data and do not have a field widget. Extra fields typically combine existing entity data and format it for display.

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.