Is it possible to lookup options from globals, and use them as options in a select field? Tried this in payload v3.12, but does not seem to work:
import { GlobalConfig } from 'payload';
export const LinkCategoriesGlobal: GlobalConfig = {
slug: 'link-categories',
fields: [
{
name: 'linkCategories',
type: 'array',
fields: [
{
name: 'name',
type: 'text',
required: true,
},
],
},
],
};
and then in the field definition something like this?
import type { Field } from 'payload';
export const relatedLinks: Field = {
name: 'related-links',
type: 'array',
fields: [
{
type: 'row',
fields: [
{
name: 'linkCategory',
label: 'Category',
type: 'select',
required: false,
options: async ({ payload }) => {
const globalData = await payload.findGlobal({ slug: 'link-categories' });
return globalData.linkCategories.map(({ name, id }) => ({
label: name,
value: id,
}));
},
admin: {
description: 'Select a link category.',
placeholder: 'Select a category...',
},
},
{
name: 'url',
label: 'URL',
type: 'text',
required: true,
admin: {
description: 'The URL for the link.',
},
},
],
},
],
};
Thanks for the links, bot... Found the title of this video, which solved my issue
https://www.youtube.com/watch?v=Efn9OxSjA6YStar
Discord
online
Get dedicated engineering support directly from the Payload team.