Skip to content

Instantly share code, notes, and snippets.

@mspacemedia
Forked from kinglozzer/SomeModelAdmin.php
Last active September 27, 2016 14:54
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 mspacemedia/322eb1ef5e7fd3241a9321010a6e0ff2 to your computer and use it in GitHub Desktop.
Save mspacemedia/322eb1ef5e7fd3241a9321010a6e0ff2 to your computer and use it in GitHub Desktop.
Sortable Silverstripe.Nice() Gridfield Columns
<?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