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

default discord avatar
blueMountain007last year
1 1

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

image

  • Selected Answer
    discord user avatar
    DanRibbens
    last year

    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 help straight from the Payload team with an Enterprise License.