2017 © Pedro PelĆ”ez
 

silverstripe-vendormodule silverstripe-copybutton

Adds copy button to the GridField.

image

dhensby/silverstripe-copybutton

Adds copy button to the GridField.

  • Friday, March 9, 2018
  • by dhensby
  • Repository
  • 1 Watchers
  • 0 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 0 Open issues
  • 7 Versions
  • 71 % Grown

The README.md

silverstripe-copybutton

Adds copy button to the GridField, (*1)

Maintainer Contact

Elvinas Liutkevičius, (*2)

, (*3)

Requirements

SilverStripe 4, (*4)

Documentation

Simply install the module using the standard method., (*5)

To add the button to the GridField you need to extend ModelAdmin and override getEditForm() method like this:, (*6)

function getEditForm($id = null, $fields = null) {
    $form = parent::getEditForm();

    $form
        ->Fields()
        ->fieldByName($this->sanitiseClassName($this->modelClass))
        ->getConfig()
        ->addComponent(new GridFieldCopyButton(), 'GridFieldEditButton') // or just ->addComponent(new GridFieldCopyButton())
    ;

    return $form;
}

This action will make exact copy of the record (with all relations and etc.). Note: you have to set configs for cascading duplications in your DataObjects to duplicate relations See: https://docs.silverstripe.org/en/4/developer_guides/model/relations/#cascading-duplications, (*7)

Sometimes you will need to do some actions just after copy operation (i.e. you'll need to remove some relations). It is easily achieved by extending DataObject and writing all the actions in the onAfterDuplicate() method., (*8)

class SomeObjectExtension extends DataExtension {

    public function onAfterDuplicate() {
        DB::query("delete from Member_SomeObject where SomeObjectID = ".$this->owner->ID);
    }

}

The Versions

09/03 2018

dev-master

9999999-dev

Adds copy button to the GridField.

  Sources   Download

BSD-3-Clause

The Requires

 

button silverstripe copy

09/03 2018

2.0.0-alpha.1

2.0.0.0-alpha1

Adds copy button to the GridField.

  Sources   Download

BSD-3-Clause

The Requires

 

button silverstripe copy

09/03 2018

1.x-dev

1.9999999.9999999.9999999-dev

Adds copy button to the GridField.

  Sources   Download

BSD-3-Clause

The Requires

 

button silverstripe copy

09/03 2018

1.0.x-dev

1.0.9999999.9999999-dev

Adds copy button to the GridField.

  Sources   Download

BSD-3-Clause

The Requires

 

button silverstripe copy

14/01 2015

v1.0.0

1.0.0.0

Adds copy button to the GridField.

  Sources   Download

The Requires

 

button silverstripe copy

14/01 2015

v0.8.0

0.8.0.0

Adds copy button to the GridField.

  Sources   Download

The Requires

 

button silverstripe copy

14/11 2014

v0.9.0

0.9.0.0

Adds copy button to the GridField.

  Sources   Download

The Requires

 

button silverstripe copy