Skip to content

Instantly share code, notes, and snippets.

@muskie9
Created August 25, 2015 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muskie9/924779d18a3996be2409 to your computer and use it in GitHub Desktop.
Save muskie9/924779d18a3996be2409 to your computer and use it in GitHub Desktop.
<?php
public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);
// $gridFieldName is generated from the ModelClass, eg if the Class 'Product'
// is managed by this ModelAdmin, the GridField for it will also be named 'Product'
$gridFieldName = $this->sanitiseClassName($this->modelClass);
if($gridFieldName=='Speaker'){
$gridField = $form->Fields()->fieldByName($gridFieldName);
$gridField->getConfig()->addComponent(new GridFieldOrderableRows());
}
$form
->Fields()
->fieldByName($this->sanitiseClassName($this->modelClass))
->getConfig()
->removeComponentsByType('GridFieldEditButton')
->removeComponentsByType('GridFieldDeleteAction')
->removeComponentsByType('GridFieldDetailForm')
->addComponent(new GridFieldDetailFormCustom())
->addComponent(new GridFieldCopyButton())
->addComponent(new GridFieldEditButton())
->addComponent(new GridFieldDeleteAction())
;
return $form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment