Last active
June 9, 2016 15:03
-
-
Save mattrayner/b4305f23cd2689d503fb1cf8911012b5 to your computer and use it in GitHub Desktop.
SilverStripe custom admin base url fix for ReportAdmin
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
ReportAdmin: | |
extensions: | |
- 'ReportAdminExtension' |
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 ReportAdminExtension extends Extension { | |
public function updateEditForm($form) { | |
$gridField = $form->Fields()->dataFieldByName('Reports'); | |
if ($gridField instanceof GridField) { | |
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns'); | |
$columns->setFieldFormatting(array( | |
'title' => function($value, &$item) { | |
$link = Controller::join_links( | |
Config::inst()->get('AdminRootController', 'url_base'), | |
Config::inst()->get('ReportAdmin', 'url_segment'), | |
get_class($item) | |
); | |
return sprintf( | |
'<a href="%s" class="cms-panel-link">%s</a>', | |
Convert::raw2xml($link), | |
Convert::raw2xml($value) | |
); | |
} | |
)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment