0

I have three content types:

  1. organization profile
  2. internship posting
  3. hours submission

The 'hours submission' content type has two entity reference fields:

  1. Entity reference for 'organization profile' nodes
  2. Entity reference for 'job posting' nodes

I'd like to pass the NID from the first entity reference such that the second entity reference is filtered (only shows nodes that are associated with that NID).

The 'job posting' content type is tied to an 'organization profile' via an entity reference field.

Any help or guidance would be appreciated.

0

2 Answers 2

2

My solution is to:

  1. Pre-populate and disable the first entity reference field with a node ID
  2. Add an extra path component with the same nid and have the second field use an entity reference view with default: Path Component 4

So the URL looks like /node/add/hacky/123?field_solution=123.

While hacky, it has uses, especially if you want to filter fields that don't have a connection. In that case the URL could be /node/add/hacky/123/456?field_solution=789.

1
  • 1
    Thanks for sharing this solution! I've actually implemented this approach into the approach that I shared (first NID is pre-populated via url params) to simplify the UI.
    – ymdahi
    Commented Jul 28, 2016 at 20:10
0

The Dynamic Dependent Fields (DDF) module does exactly what I described above.

The module introduces a new view mode: "Filter by an entity reference view with dynamic arguments". Then you can filter the entity reference view you set up with the value from a field in the entity.

In the Entity Reference View, use contextual filters to filter the results.

For example, I added the NID (provided by content ID) as a contextual filter.

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.