### What?
Fixes CSV export support for polymorphic relationship and upload fields.
### Why?
Polymorphic fields in Payload use a `{ relationTo, value }` structure.
The previous implementation incorrectly accessed `.id` directly on the
top-level object, which caused issues depending on query depth or data
shape. This led to missing or invalid values in exported CSVs.
### How?
- Updated getCustomFieldFunctions to safely access relationTo and
value.id from polymorphic fields
- Ensured `hasMany` polymorphic fields export each related ID and
relationTo as separate CSV columns
22 lines
382 B
TypeScript
22 lines
382 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import { postsSlug } from '../shared.js'
|
|
|
|
export const Posts: CollectionConfig = {
|
|
slug: postsSlug,
|
|
admin: {
|
|
useAsTitle: 'title',
|
|
},
|
|
versions: {
|
|
drafts: true,
|
|
},
|
|
fields: [
|
|
{
|
|
name: 'title',
|
|
label: { en: 'Title', es: 'Título', de: 'Titel' },
|
|
type: 'text',
|
|
required: true,
|
|
},
|
|
],
|
|
}
|