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.

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.

| improve this answer | |
  • 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 Jul 28 '16 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.