Allow non summary fields to be used as grid field export fields (#9248)

Allow non summary fields to be used as grid field export fields
This commit is contained in:
Guy Marriott 2019-09-18 15:33:25 -07:00 committed by GitHub
commit 109ac3f75f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,6 +216,9 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
/** @var GridFieldDataColumns|null $gridFieldColumnsComponent */ /** @var GridFieldDataColumns|null $gridFieldColumnsComponent */
$gridFieldColumnsComponent = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class); $gridFieldColumnsComponent = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
$columnsHandled = ($gridFieldColumnsComponent)
? $gridFieldColumnsComponent->getColumnsHandled($gridField)
: [];
/** @var DataObject $item */ /** @var DataObject $item */
foreach ($items->limit(null) as $item) { foreach ($items->limit(null) as $item) {
@ -231,7 +234,7 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP
} }
$value = $columnHeader($relObj); $value = $columnHeader($relObj);
} elseif ($gridFieldColumnsComponent) { } elseif ($gridFieldColumnsComponent && array_key_exists($columnSource, $columnsHandled)) {
$value = strip_tags( $value = strip_tags(
$gridFieldColumnsComponent->getColumnContent($gridField, $item, $columnSource) $gridFieldColumnsComponent->getColumnContent($gridField, $item, $columnSource)
); );