The data from the form should be send me by email as a csv so i can open it in Excel.
This works fine with normal fields but not with Arrays (checkboxgroup).
I added this code to the custom php code before email:
<?php
// date and time
$timestamp = time();
$datum = date("d-m-Y",$timestamp);
// some variables
$filename = 'kischwi';
$filepath = 'tmp/';
$filename = $filename . '.csv';
// creating the CSV row
$csv_row = $form->data['vorname-eltern']
. ";" . $form->data['nachname-eltern']
. ";" . $form->data['strasse-nr']
. ";" . $form->data['plz-ort']
. ";" . $form->data['telefon']
. ";" . $form->data['e-mail']
. ";" . $form->data['geburtstag'] . ". " . $form->data['geburtsmonat'] . " " . $form->data['geburtsjahr']
. ";" . $form->data['moegliche-kurse']
. ";" . $form->data['sommerintensivkurs']
. ";" . $datum
. "\r\n" ;
// saving it in the file
$file = fopen ($filepath . $filename, 'a');
fwrite ($file, $csv_row);
fclose ($file);
// add the attachement to the form array
$form->files['csv'] = array(
'name' => $filename,
'original_name' => '',
'path' => $filepath.$filename,
'size' => '',
'link' => str_replace(JPATH_SITE.DS, JURI::root(), $filepath.$filename)
);
?>
The fields 'moegliche-kurse' and 'sommerintensivkurs' are checkboxgroups and in the Excel it only shows "Array" instead of the content. I have no idea how i should add the foreach statement or something similar. All values in the Array should be in the same column.
A second Problem are the letters ä, ö an ü. They are show as ö in Excel. I think something with encoding?
Thanks for any suggestions.