Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By MrSnrub on
Master Content Type:
Has a field called "Assigned User" that is an entity reference to User. When creating nodes of this content type this field gets assigned to certain users in our system.
Child Content Type:
Has a field called "Related node" that is an entity reference to nodes of type Master.
When a user creates nodes of type Child, he or she selects the "Related node" drop-down box, the user should only see Master nodes that have "assigned user" set to that user's username, and not nodes assigned to other users. How do I do this?
Comments
If the user is creating the
If the user is creating the node, then the author is the person who created the node.
If the "assigned user" ever going to be not the author of the node?
The "assigned" user does not
The "assigned" user does not create nodes of type Master. That is done by a completely different set of users.
The "assigned" user will always be the author the nodes of type Child.
You can use a view to
You can use a view to populate the entity reference field to content of type master.
So you could create a view that uses a relation on the assigned field that references the user and then add a filter on user:current that uses that relation.
I'm sorry, I don't quite
I'm sorry, I don't quite understand. Could you please explain in more detail?
I go to Structure --> Views --> Add new view.
I say to show Content of type Master.
I click "Continue and Edit."
Under "Displays" I click Add --> Entity Reference.
I click on the Entity Reference Settings link and click on "Content: Title," then click on "Apply (this display)."
I expand the "Advanced" tab and go to Relationships --> Add.
And this is where I'm stumped. How do I add the "user: current" filter?
Never mind. It took quite a
Never mind. It took quite a while, but I figured it out. Here is what I did: