Export form data to a CSV file and save it on the server

deltafidesign 14 Nov, 2014
HI,

I would like to know if is possible to have such scenario with Chronoforms V5.

When user submit the form I want to save all data to a csv file and save the file somewhere on the server.

How to? Possible?

Thanks in advice.
GreyHead 14 Nov, 2014
Hi deltafidesign,

There is a CSV Export action in the Data Management actions group in the Setup tab.

Bob
deltafidesign 14 Nov, 2014
Hi Bob,

I've already saw that action but I don't understand how it works. It asks me for a DB table that I should choose from where export datas?

I want just to export datas that user filled in the form everytime he submit it.

Please give me some instruction.🙂
GreyHead 15 Nov, 2014
Hi deltafidesign,

If you use the Data Path option the table is ignored. I think that you'd need to either add array names to the inputs e.g. save_this[name], save_this[email], etc. or copy the values you want to save into a sub-array of the $form->data[''] array e.g. $form->data['save_this']['name'], etc.

I have never really understood why you would want to do this? It seems much easier to save to the database and export a batch of records from there.

Bob
deltafidesign 15 Nov, 2014
Hi Bob,

thanks for reply. I need a .csv file with data submitted by user to let a 3th party software load those data from that file.
Austre 10 Mar, 2015
Hi Bob,

I'm exploring this Export csv and looking your example "$form->data['save_this']['name']", i put this Custom Code:

<?php
$form->data["csvData"]["Nome"] = "Neto";
$form->data["csvData"]["Sexo"] = "Masculino";
?>


[attachment=0]chrono01.JPG[/attachment]
[attachment=1]chrono02.JPG[/attachment]

After, i add Export CSV like this
[attachment=2]chrono03.JPG[/attachment]
[attachment=3]chrono04.JPG[/attachment]
Austre 10 Mar, 2015
With those configs my CSV file comes blank.
What's wrong?😲
GreyHead 10 Mar, 2015
Hi Austre,

Please try
<?php
$form->data["csvData"][0]["Nome"] = "Neto";
$form->data["csvData"][0]["Sexo"] = "Masculino";
?>
with the added [0] - the exporter is expecting an array of sub-arrays each containing the data for one row of the exported file.

Bob
Austre 11 Mar, 2015
Now it works!
Thanks Bob!
:D
This topic is locked and no more replies can be posted.