relationTo with globals

default discord avatar
reepicheep05
4 months ago
2

Hello all, I'm trying to set up a link field in the admin UI. I used the example from the payload website which provides a dropdown which populates with pages/posts from a few collections.



I have a few pages that I am setting up as globals, and I am looking for a way to include these in the select dropdown. Does anyone have a suggestion?



Here is the relevant field entry:



{
      name: 'reference',
      label: 'Document to link to',
      type: 'relationship',
      relationTo: ['pages', 'posts', 'case-studies'],
      required: true,
      maxDepth: 1,
      admin: {
        condition: (_, siblingData) => siblingData?.type === 'reference',
      },
    },


I have tried adding the global slug in the array, but that does not work.

  • default discord avatar
    jarrod69420
    4 months ago

    There’s no way to get them to show up in those select inputs. Curious types of content you are creating as globals? I would likely recommend against that for other reasons

  • default discord avatar
    reepicheep05
    4 months ago

    Ok thank you for the info Jarrod. I had planned to create my Home page and a few other pages which use a different template as globals. Maybe I will reorganize those pages into regular Collections.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.