- Issue created by @ladybug_3777
- πΊπΈUnited States john.oltman
Hi, I tried creating a similar view on D7 and saw a relationship named "Associated registration via the registration's author entity." Was that the one you are using? On D9/10 there is a core issue β¨ provide Views reverse relationships automatically for entity base fields Needs review because the similar relationship is not created. To solve that until the issue is resolved, you need to install the Entity API contrib module β and then add the following to a custom module:
/** * Implements hook_entity_type_alter(). */ function my_module_entity_type_alter(array &$entity_types) { if (isset($entity_types['registration'])) { $entity_types['registration']->setHandlerClass('views_data', 'Drupal\entity\EntityViewsData'); } }
Then clear cache and it will create a relationship "Relate each Registration with a user_uid field set to the user" that you can then use in your Entity Reference listing. I was able to get a list of the users who had registered for a given event by using that relationship and adding Contextual Filters for Registration:Entity Type ID and Registration:Entity ID and using the "Provide a default value" option. For the default values I used "Host entity type ID from URL" and "Host Entity ID from URL" respectively.
Try that and see if that works for you, or post with more details so I can try and figure out what the D7 version of the view is doing. The relationship you tried to use for D9/10 is for host entities, if you had enabled the User content type to be a host entity (highly unlikely); normally it is used in a context in which the relationship is for a Node or Commerce Product Variation.
- Status changed to Postponed: needs info
over 1 year ago 1:45pm 26 May 2023 -
john.oltman β
committed f9523075 on 3.0.x
Issue #3361113: Add reverse relationships when Entity module is...
-
john.oltman β
committed f9523075 on 3.0.x
- Status changed to Fixed
over 1 year ago 2:12pm 11 June 2023 - πΊπΈUnited States john.oltman
Since this is going to be a common need, I have added the suggested code to the Registration module. So all people need to do to get the extra relationships is install the Entity API module. https://www.drupal.org/project/entity β
I'll document this in the README
Automatically closed - issue fixed for 2 weeks with no activity.