Is it possible to create a relational field that relates to two different models?
For example: I have a lesson model, and I want it to have a challenge relational field. For that field, I want the user to either be able to select a MultipleChoiceChallenge, or a CodeChallenge.
After more investigation, one way to do this would be a component/repeater field, which is a pretty good solution, but I still wonder if it’s possible to specify this directly on the relational field
Hi there @oriooctopus maybe you could create a collection of the CodeChallenge, and For Multiple Choice, then you can have a Lession which can have one to many / one to one etc with those collections.
But yes component repeater field is also possible.
Thanks for your response. Unfortunately I need an order between the code/multiple choice challenges, so I don’t think your suggestion would work
You can’t make two collections, get both collections to the frontend then sort them in order (even making an order flag etc). If you need an order add an order ID or anything that you can order / sort by and use a sort field in strapi too when retrieving data.
I mean I’m using something similar for a project and that was what I ended up doing.
Though I ended up refactor it to have an endpoint that queries both collections map them together and serves that back.
Kinda, it’s called a polymorphic relation but we do not currently handle these well in the admin panel. We do use them internally but we don’t offer it a relation type yet for normal usage.