How to get relationship field's targeted collection in Admin UI #891
-
Hi everyone, The only work around I found currently is all relationship field change to multiple: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @khakimvinh — I'm following what you are looking to do. I would avoid changing the fields to multiple like you said, because like you noticed, that changes the shape of the data. You probably want your plugin to handle all four types of relationship field data. You can access the config for the collection you're working in, and find the relevant field that corresponds to the field that you're interacting with. // import the hook
import { useConfig } from 'payload/components/utilities';
// use it in your React component
const config = useConfig(); Could you do that? To find the field recursively, you would need to parse the field's But, nested fields, like say one within an array, would have a path like Does that make sense? |
Beta Was this translation helpful? Give feedback.
Hey @khakimvinh — I'm following what you are looking to do.
I would avoid changing the fields to multiple like you said, because like you noticed, that changes the shape of the data. You probably want your plugin to handle all four types of relationship field data.
You can access the config for the collection you're working in, and find the relevant field that corresponds to the field that you're interacting with.
Could you do that? To find the field recursively, you would need to parse the field's
path
that you are trying to work with. For example, t…