#Customize Array Naming Based on Single Field?
1 messages · Page 1 of 1 (latest)
Original message from @lilac peak - Moved from #general message
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
@lilac peak Like this?
admin: {
components: {
RowLabel: ({ data, index }: RowLabelArgs) => {
return data?.title || `Slide ${String(index).padStart(2, '0')}`
},
},
},
Data I believe has the field values in the array
Let me give it a try.
Function or React component to be rendered as the label on the array row. Receives ({ data, index, path }) as args
how did you add it to your collection?
{
name: 'variant',
type: 'array',
label: false,
required: true,
validate: validateVariant,
admin: {
components: {
RowLabel: ({data}) => data?.name || 'New Variant' // TODO: Fix data undefined issue.
}
},
fields: [
{
type: 'row',
fields: [
{
name: 'name',
type: 'text',
required: true,
}
]
},
{
type: 'row',
fields: [
{
name: 'stripeProductId',
type: 'text',
}
]
}
],
minRows: 1,
labels: {
singular: 'Variant',
plural: 'Variants',
}
}
I even try to copy the sample code from https://payloadcms.com/docs/beta/fields/array#example. It show undefined too
I have the same issue
It looks like this is a known issue and has not been fixed yet.