2

In Drupal 8, I have a content type for "Advances" that contains an Entity Reference field to "Technology". Each instance of an Advance should be of a certain type of Technology, which has Prerequisite technology types. The goal is therefore to have the Technology entity reference limited only to those contents whose Prerequisites appear in the Advances' existing related Technology data.

For example, the Technology "Optical disc" would have the Prerequisites "Laser", "Plastic". While adding a new Advance, the related "Technology" list to select from would include only those Technology data whose Prerequisites are in the existing Advances data. Therefore if the Advances already include "Laser" and "Plastic", then "Optical disc" would appear in the Technology select list. If "Laser" and "Plastic" do not appear in Advances, then "Optical disc" would not appear in the Technology select list.

I have set up an Entity Reference Display View. With this I can filter the Technology data in the select list. For example, I have set up a "Filter Criteria" option for Prerequisite as Not Empty, so that only Technology data with at least one Prerequisite appear in the select list.

However, I have not found a way to filter the list so that only Technology data with their Prerequisite data appearing in the Advances data appear in the select list.

I have looked through all the Filter Criteria and Contextual Filters. I do not see any way to accomplish this. From web search results, it appears that Drupal 7 had a PHP contextual filter, which could potentially have helped, however I do not see this in Drupal 8.

Also, some other questions seem to suggest a Global Fields Comparison Filter, although this also seems to have disappeared from Drupal 8.

How can one filter an Entity Reference according to values that appear in a field?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.