I added this to SubmittedFormReportField.php. Here's the code:
foreach($tmp as $array) {
$csvHeaderNames[] = $array['Name'];
$csvHeaderTitle[] = $array['Title'];
}
// Get the created dates for each record (ADD THIS)
$strCreated = "SELECT DISTINCT Created FROM SubmittedForm WHERE ID IN (" . implode(',', $inClause) . ")";
$tmpCreated = DB::query($strCreated);
foreach($tmpCreated as $array) {
$csvCreated[] = $array['Created'];
}
And...
// For every row of data (one form submission = one row) (SLIGHTLY MODIFFIED)
foreach($rows as $row) {
// Loop over all the names we can use
$csvData .= "\"" . $csvCreated[$j] . "\", ";
$j++;
for($i=0;$i<count($csvHeaderNames);$i++) {
// If there is no data for this column, output it as blank instead
if(!isset($row[$i]) || !$row[$i]) {
$csvData .= '"",';
} else {
$csvData .= '"'.str_replace('"', '\"', $row[$i]).'",';
}
}
// Start a new row for each submission
$csvData .= "\n";
}