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

default discord avatar
zhounewz
11 months ago
1 1

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

image

  • discord user avatar
    DanRibbens
    Payload Team
    7 months ago

    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
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.