Skip to content

Instantly share code, notes, and snippets.

@kinglozzer
Created April 13, 2016 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kinglozzer/330f484c6ff7bb0fc1017a852c981d47 to your computer and use it in GitHub Desktop.
Save kinglozzer/330f484c6ff7bb0fc1017a852c981d47 to your computer and use it in GitHub Desktop.
<?php
class SomeModelAdmin extends ModelAdmin {
private static $managed_models = array(
"MyDataObject"
);
public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);
$gridField = $form->Fields()->dataFieldByName('MyDataObject');
$dataColumns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$dataColumns->setDisplayFields(array(
'Order.Surname' => array(
'title' => 'Customer name',
'callback' => function($record) {
$order = $record->Order();
return $order->FirstName . ' ' . $order->Surname;
}
)
));
return $form;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment