Created
April 13, 2016 14:21
-
-
Save lozcalver/330f484c6ff7bb0fc1017a852c981d47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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