Like what we’re doing? Star us on GitHub!

Can the entry generated by the Duplicate operation be specified as draft state?

zhounewz
5 months ago
1 1

Can the entry generated by the Duplicate operation be specified as draft state?

image

  • DanRibbens
    Payload Team
    last month

    Hi @zhounewz, this is now possible using the beforeDuplicate admin hook.

    Here is an example of how this would look in your case:

    const Posts: CollectionConfig = {
      slug: 'posts',
      admin: {
        hooks: {
          beforeDuplicate: ({ data }) => {
            return {
              ...data,
              _status: 'draft',
            };
          },
        },
      },
      versions: {
        drafts: true,
      },
      fields: [
        // ...
      ],
    };

    Cheers!

Open the post
Continue the discussion in GitHub
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More