Adds a duplicate button to GridField in the CMS that enables duplicating of dataobjects.
Forked from jinjie/duplicate-dataobject and updated to support SS5.
composer require roseblade/ss-duplicate-dataobject
This module uses the built in DataObject duplication.
See
- https://api.silverstripe.org/4/SilverStripe/ORM/DataObject.html#method_duplicate
- https://docs.silverstripe.org/en/4/developer_guides/model/relations/#cascading-duplications
// Add component on existing GridField
$fields->fieldByName('Root.Main.MyGridField')
->getConfig()
->addComponent(new GridFieldDuplicateAction());
// Add component on new GridField
$fields->push(
GridField::create(
'MyGridField',
'MyGridField'
)->addComponent(new GridFieldDuplicateAction())
);
Developed by Jin Jie @ Swift DevLabs