Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

relationTo with globals

default discord avatar
reepicheep0510 months ago
1

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.



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.

  • discord user avatar
    jarrod_not_jared
    2 years 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

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.