Join Field with filterOption #8937
michalklor
started this conversation in
Feature Requests & Ideas
Replies: 2 comments 1 reply
-
Hi @michalklor, Can you give me an example configuration that I can toy with? I think what you're asking for should be possible. I was just experimenting with the following and it does work: {
collections: [{
slug: 'categories',
fields: [
{
name: 'name',
type: 'text',
},
{
name: 'posts',
type: 'join',
collection: 'posts',
on: 'category',
},
{
name: 'isFiltered',
type: 'checkbox',
defaultValue: false,
},
],
}, {
slug: 'posts',
fields: [
{
name: 'title',
type: 'text',
},
{
name: 'category',
type: 'relationship',
relationTo: categoriesSlug,
filterOptions: {
isFiltered: {
equals: false,
},
},
},
],
}
]
// etc... The only awkward thing to note is that I did have to save the category and even if I said this category should be filtered using the checkbox, the UI still let's you click Add Post. It then errors because the prefilled category isn't allowed to be used. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description:
When using the filterOptions function to filter data in collections that include join fields, I've encountered a limitation where the joins parameter is not supported. This restriction prevent our ability to filter documents, such as media, based on their association with other documents, like a specific post.
Current Behavior:
Currently, we can only use the where clause for filtering, which significantly limits the functionality of our applications that relies on join fields for filtering options.
Expected Behavior:
I would like to propose the addition of join fields support within the filterOptions function. Since the join fields functionality is already available in the REST API of Payload CMS, it would be beneficial to have it implemented in filterOptions as well. This enhancement would allow us to filter data more effectively with relationships between documents.
Use Case:
For example, filtering media documents based on their association with a specific post would enhance the user experience and data management capabilities.
Beta Was this translation helpful? Give feedback.
All reactions