Files
payload/test/plugin-import-export/collections/Posts.ts
Patrik 6d768748a0 fix(plugin-import-export): csv export for polymorphic relationship fields (#12926)
### 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
2025-06-25 11:44:31 -04:00

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,
},
],
}