i am using beforeValidate to create a unique slug when a new post is created. it works just fine as it is now
The problem i find is that if i try to duplicate the field in the adminUI it wont work anymore.
I am wondering how i can get in between what ever the duplicate button does?
hooks: {
beforeValidate: [
async ({ data, value }) => {
return await creatuSlug(
data,
value,
data.postName,
"posts"
);
},
],
},
The beforeDuplicate hook is an async function that accepts an object containing the data to duplicate, as well as the locale of the doc to duplicate. Within this hook, you can modify the data to be duplicated, which is useful in cases where you have unique fields that need to be incremented or similar, as well as if you want to automatically modify a document's title.
@Raoul sounds like you are all set, right?
i think i am 🙂
@jarrod_not_jared I got back to this now, seems that i am stuck after all, can't seem to get in between the duplication process.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.