Chained Select Fields #1449
-
Hi All, I have two select fields that I need to "chain". It is a basic project management tool and it has the following collections: "Organizations", "Projects", "Tasks". In the tasks collection I have one field "organizations" that is a relationship and displays all organizations. The other is "projects" which is also a relationship and displays all projects. I would like to make it such that when you select a specific organization, the projects list will only display the projects of that organization. I could do this in a traditional monolith with an Ajax call and a subsequent filter on the projects list via a query. I am totally at a loss how to solve this in Payload though. Any help would be greatly appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
This is what the https://payloadcms.com/docs/fields/relationship#filtering-relationship-options |
Beta Was this translation helpful? Give feedback.
This is what the
filterOptions
property is for on the relationship field.You will return a query on your projects field's filterOptions to only get the projects equal to the organization ID that is selected from your data or siblingData.
https://payloadcms.com/docs/fields/relationship#filtering-relationship-options