Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

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

default discord avatar
blueMountain0072 years ago
1 1

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

image

  • Selected Answer
    discord user avatar
    DanRibbens
    2 years 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!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.