fix: field formatting to correct include link

This commit is contained in:
Will Rossiter 2022-06-13 11:53:44 +12:00 committed by GitHub
parent 6782048463
commit d87dbc8367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,12 +27,16 @@ class CommentsGridFieldConfig extends GridFieldConfig_RecordEditor
/** @var GridFieldDataColumns $columns */
$columns = $this->getComponentByType(GridFieldDataColumns::class);
$columns->setFieldFormatting([
'ParentTitle' => function ($value, &$item) {
return sprintf(
'<a href="%s" class="cms-panel-link external-link action" target="_blank">%s</a>',
Convert::raw2att($item->Link()),
$item->obj('ParentTitle')->forTemplate()
);
'Parent.Title' => function ($value, &$item) {
if ($link = $item->Link()) {
return sprintf(
'<a href="%s" class="cms-panel-link external-link action" target="_blank">%s</a>',
Convert::raw2att($link),
$item->obj('ParentTitle')->forTemplate()
);
} else {
return $item->obj('ParentTitle')->forTemplate();
}
}
]);