GridFieldBulkEditingTools icon indicating copy to clipboard operation
GridFieldBulkEditingTools copied to clipboard

Add Model Admin example to ReadMe

Open jonom opened this issue 10 years ago • 0 comments

Thought it would be good to add an example to the docs on how to allow bulk editing on a Model Admin interface. Adapting instructions from BlackDog, you end up with (where MyDataObject is the class the gridfield is showing)

class MyDataObjectAdminBulkManagerExtension extends Extension {

    function updateEditForm(&$form) {
        if($this->owner->modelClass == 'MyDataObject') {
            //Update the automatically generated Model Admin interface with bulk editing capabilities
            $form->Fields()->fieldByName('MyDataObject')->getConfig()->addComponent(new GridFieldBulkManager());
        }
    }

}

and apply extension to relevant model admin instance via yml config with

MyDataObjectAdmin:
  extensions:
    - MyDataObjectAdminBulkManagerExtension

jonom avatar Feb 20 '15 00:02 jonom