2

First, I'd like to start with my content structure:

Classrooms:
Title
Students_Attending [entity reference field with multiple values]

Students:
Name
Gender
Country
Classes
Avatar

Ok now, let's say I have a View that essentially lists Students. It has exposed fields for gender, country, and classes. You can use these to narrow down the subset of students listed by the view.

I want to add another exposed filter to this view. This filter will be a select box with a list of Classrooms, and you are able to select multiple classrooms. What this does in practice is that it limits the resulting subset list of Students to those that are referenced by the "Students_Attending" entity reference field of the "Classroom(s)" that was/were selected. So if I select "Classroom 1" on the exposed filter, the View will only list students who are referenced by the "Students_Attending" field of "Classroom 1."

How do I achieve this with Views on Drupal 8? Is it even possible with Views alone?

  • add relationship of referenced entity, add filter of students_attending and expose filter – No Sssweat Jul 28 '16 at 23:29
  • that doesn't work. it gives me a field to type in an ID. Not a list of classrooms to select from. – user3445644 Jul 29 '16 at 2:20
0

It's not possible with views alone without custom code or another module.

See https://www.drupal.org/sandbox/el/2698765 or D8 entity reference exposed filter for ideas on how to proceed.

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.