Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

User Defined Forms Export - Adding Dates To CSV


Go to End


1467 Views

Avatar
Usability Counts

Community Member, 5 Posts

31 January 2010 at 7:44am

Edited: 31/01/2010 7:45am

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";
}