When duplicating a blog post with a unique field (slug in my case) I get the error 'The following field is invalid: slug'
While I understand why this is happening, would it be possible to duplicate an item and then clear the unique field? Allowing the user to duplicate and requiring the unique field to be updated
You can use the
beforeDuplicate
hook to assign a new unique slug to the document
https://payloadcms.com/docs/configuration/collections#admin-hooksCan I follow up on this question?
Would it be possible to prompt the user for that unique slug instead of doing it programatically?
hi guys i got this same error
info:
Binaries:
Node: 20.11.1
npm: 10.2.4
Yarn: 1.22.22
pnpm: 10.3.0
Relevant Packages:
payload: 3.23.0
next: 15.1.5
@payloadcms/db-mongodb: 3.23.0
@payloadcms/email-nodemailer: 3.23.0
@payloadcms/graphql: 3.23.0
@payloadcms/next/utilities: 3.23.0
@payloadcms/payload-cloud: 3.23.0
@payloadcms/plugin-cloud-storage: 3.23.0
@payloadcms/richtext-lexical: 3.23.0
@payloadcms/storage-azure: 3.23.0
@payloadcms/translations: 3.23.0
@payloadcms/ui/shared: 3.23.0
react: 19.0.0
react-dom: 19.0.0
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 24.3.0: Thu Jan 2 20:22:00 PST 2025; root:xnu-11215.81.4~3/RELEASE_X86_64
Available memory (MB): 16384
Available CPU cores: 16
error in terminal:
[TypeError: Invalid state: Controller is already closed] {
code: 'ERR_INVALID_STATE'
}
error in network:
URL:
http://localhost:3000/api/pages/67b2e5b7e577104024618dce/duplicate?locale=enmessage: "The following field is invalid: email"
name: "ValidationError"
i cant find any reported bug regarding this, can you help me here
CAN YOU PLEASE HELP ?
ONLY EMAIL NAMED VALUE IS USED IN src/collections/users.ts
import type { CollectionConfig } from 'payload'
export const Users: CollectionConfig = {
slug: 'users',
admin: {
useAsTitle: 'email',
},
auth: true,
fields: [
// Email added by default
// Add more fields as needed
],
}
Star
Discord
online
Get dedicated engineering support directly from the Payload team.