I've an custom entity type : "card", witch has a property named "owner", an entity_reference to the owner of the card.

My custom entity is pretty basic and has been created trough Drupal Console.

If I create a view on Cards I can use the relationship to get the "owner" fields and properties accessible.

But if on a Users based view, the reverse relationship is not present : I can't access card information's from the owner.

Am-I missing something ? Do I have to set up this reverse relationship somewhere ?

Thanks in advance !

1 Answer 1


Ok ! finally found out !

I had to use the hook_views_data_alter to put the relationship on the user :

 * Implements hook_views_data_alter().
function MYMODULE_views_data_alter(array &$data) {
  $data['users_field_data']['cards'] = [
    'title' => t("Users cards"),
    'help' => t("Link the users to their cards"),
    'relationship' => [
      'group' => t('Cards'),
      'label' => t("User cards"),
      'base' => 'cards', // database table
      'base field' => 'owner', //database field to join on
      'relationship field' => 'uid',
      'id' => 'cards',
  • Thanks, just a note, for the id key, I used the value standard for the standard relationship plugin handling, then it worked. Commented Aug 25, 2021 at 22:11

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.