Permalink
Browse files

BUGFIX Setting MIME type for TableListField export explicitly, as HTT…

…P::get_mime_type() requires a path to an actual file, in this case we're exporting data directly to the browser.
  • Loading branch information...
1 parent 2392f93 commit 39bd89879ec97580db3faadef932515a40a8405a @halkyon halkyon committed May 11, 2012
Showing with 4 additions and 4 deletions.
  1. +4 −4 forms/TableListField.php
View
8 forms/TableListField.php
@@ -961,10 +961,10 @@ function removeCsvHeader() {
* @todo Make relation-syntax available (at the moment you'll have to use custom sql)
*/
function export() {
- $now = Date("d-m-Y-H-i");
+ $now = date("d-m-Y-H-i");
$fileName = "export-$now.csv";
- // No pagination for export
+ // No pagination for export
$oldShowPagination = $this->showPagination;
$this->showPagination = false;
@@ -973,8 +973,8 @@ function export() {
$this->showPagination = $oldShowPagination;
if($fileData = $this->generateExportFileData($numColumns, $numRows)){
- return SS_HTTPRequest::send_file($fileData, $fileName);
- }else{
+ return SS_HTTPRequest::send_file($fileData, $fileName, 'text/csv');
+ } else {
user_error("No records found", E_USER_ERROR);
}
}

0 comments on commit 39bd898

Please sign in to comment.