Directus headless CMS - Display attributes from 3rd table in dropdown One-To-Many

Viewed 847

Table A = {Student_ID,Student_Name}, Table B = {Teacher_ID,Teacher_Name}, Table C = {Relationship_ID,Student_ID,Teacher_ID}

Table C captures a relationship between A and B and therefore has a many-to-one relationship with both Table A and B. Here we create a visible drop down column with the names of the students and teachers

When creating a table D which has a many-to-one relationship with table C, how can we create a visible drop down column that captures the relationship from table C but with the student- and teacher names when it's not contained in table C?

1 Answers

A great question. Which version of Directus are you using?

This was a bit more complex in v6.x and required some custom code I think. But in the new v7 (which is in RC.3 right now and will be released in the next few days) you can accomplish it with dot notation.

v7: In the options of the dropdown, you can choose what data to make visible. If it is not a field on the actual item, then you can reference the relational data like this: actual-field.related-field-to-show

Using this method you can go as deep as you need: eg root.level-1.level-2 ... but the more complex and deeper the data, the more time it will take to fetch.

Related