diff --git a/forms/gridfield/GridFieldExportButton.php b/forms/gridfield/GridFieldExportButton.php index 307399e20..b67f63b33 100644 --- a/forms/gridfield/GridFieldExportButton.php +++ b/forms/gridfield/GridFieldExportButton.php @@ -110,8 +110,13 @@ class GridFieldExportButton implements GridField_HTMLProvider, GridField_ActionP // determine the CSV headers. If a field is callable (e.g. anonymous function) then use the // source name as the header instead + foreach($csvColumns as $columnSource => $columnHeader) { - $headers[] = (!is_string($columnHeader) && is_callable($columnHeader)) ? $columnSource : $columnHeader; + if (is_array($columnHeader) && array_key_exists('title', $columnHeader)) { + $headers[] = $columnHeader['title']; + } else { + $headers[] = (!is_string($columnHeader) && is_callable($columnHeader)) ? $columnSource : $columnHeader; + } } $fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";