-
-
Save mspacemedia/322eb1ef5e7fd3241a9321010a6e0ff2 to your computer and use it in GitHub Desktop.
Sortable Silverstripe.Nice() Gridfield Columns
This file contains 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( | |
'Field' => array( | |
'title' => 'Field name', | |
'callback' => function($record) { | |
return $record->dbObject('Field')->Nice(); | |
} | |
) | |
)); | |
return $form; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment