Parent & child relationship/field
Yannis Kadiri
The easiest example to explain is laid out like this, we have the following models:
- Make
- Model
- Sales
In this context we are talking about cars, so the make would contain a list of car manufacturers (Subaru, Toyota, Ford, Chevy, ect). Thus the model would contain some options like WRX, GT86, Mustang, Corvette.
The way we would setup the sales model would be a oneWay relation to each make/model, and in the context of this request when we create a new "sale" we would select the make (say subaru) now when I go to select the model I should only be able to see/select the "WRX" model since it's made by Subaru.
I should not be able to select "Toyota" "Mustang" as that car doesn't exist.
See for more information: https://github.com/strapi/strapi/issues/8708
Marco Autiero
Merged in a post:
Hierarchical Relationships
D
David Barratt
For content types like Comments, Menus, or anything with a hierarchy (or a tree), it would be useful to have a field that allows you to specify the
parent
entry.Behind the scenes, Strapi could use a Closure Table (https://dirtsimple.org/2010/11/simplest-way-to-do-tree-based-queries.html) to make querying the entire tree fast.
j
jacek
Is it possible you can already do that with a relation field that points to same type? I use a relation field in article type to add related articles, but it could be used to get a parent. And you can write a simple endpoint in the controller that adds the whole tree to the response.
Dimitrii Tkach
I wrote a plugin that introduces the custom field that does this
In the first gif you can see normal behavior
In the second gif you can see the behavior with the custom field
raku
Dimitrii Tkach
good!!!!!!
Dimitrii Tkach
I just wrapped up the documentation for the plugin, strapi-plugin-parent-child-relationships, and it’s officially live on npm! You can check it out here:
For those currently using the old version, I’ve included instructions on how to transition to the new plugin:
N
Nguyen Nam
We need this, please do it in Srapi V5
A
Alexandre Phiev
Still very interested in that key CMS feature.
E
Ellis Madagan
100% something we'd use.
Michael
We need RBAC to filter the relation dropdown ASAP!!
currently our solution would be intercepting the controller['relations'] through register function. But that is not clean. Please put this in your priority roadmap.
This kind of functionality is very important for big corporations type use.
thanks for the great product!
Patrik Albertsson
We really need this in our upcoming project. Is there any updates on this feature? Or some workaround?
Derrick Mehaffy
Merged in a post:
Allow constraints/filters in relationships
Javier Diaz Chamorro
Currently, we can define the relation model but we cannot define constraints or filters in this relation.
Use Case
You define a new blog block called
Popular Posts
, and to improve the editor's experience and prevent errors from occurring it should show only those posts that match to some category.Otherwise, there should be the possibility to show other fields in the selection dropdown in the relationship, for example,
Title - Category
, in order to make a more accurate search.Szymon Jankowski
I'm quite suprised this feature is not prioritized. Could we at least have any information if it's considered worth developing and planned for any future?
Load More
→