Buy Now
Sign in

Upload contents of a form to CSV

hyperlast , May 02 2019, 14:33
H
hyperlast 4
May 02 2019, 14:33 #386479
Hi guys,
Really happy with Chronoforms so far! I am building a candidate registration form using Wordpress on the latest build of CFv6, with every submission I want a CSV file to be generated with candidate details so it can then be taken over by our main DB and put into the system. I have a CSV on-submit function, the CSV gets generated, however, inside it there's only the following error:
<b>Warning</b>: fputcsv() expects parameter 2 to be array
Data gets inserted into the website database just fine. I have left the 'Data Provider' field empty as I have not a clue how to fill it out. Looking at different topics on the forum I have tried &nbsp;{var:read_data#.[n].model} which doesn't help. I am very much fresh to website development, php and sql so I will need quite a thorough explanation
Thanks for your help!
admin 27
May 03 2019, 19:00 #386492
Hi,
Please check my post here

Best regards
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
H
hyperlast 4
May 08 2019, 08:39 #386634
Thanks Max! I tried that method before on XAMPP which didn't work but now on a proper hosting it does the job just fine. Is there a way to manipulate the CSV output? I am looking to delete specific fields (first four columns generated in the CSV file are 'page', 'cont', 'chronoform' and 'event' which are not present in the data table itself) and rearrange the order of columns in the csv.
Thanks once again for your help
GreyHead 64
May 08 2019, 10:03 #386640
Hi hyperlast,
Please check this post from the thread Max linked to.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
H
hyperlast 4
May 08 2019, 13:14 #386648
Hey,
Sorry to be a pain, as I said I am very much a beginner. I have the PHP action set to
return [$this->data];
and data provider set as {var:csv_data} in the CSV action. Which fields do I need to modify and in what way in order to only select specific fields to be imported to CSV?
healyhatman 7
May 09 2019, 05:21 #386662
return [ "first_field_name" => $this->data("first_field_you_want"), "second_field_name" => $this->data("second_field_you_want")];
Web developer at SkySpider.com.au - I DO NOT work for ChronoEngine!
Donations: paypal.me/healyhatman
Professional Work: kamron@skyspider.com.au
Custom CF / CC Plugins and Extensions: skyspider.com.au/store
H
hyperlast 4
May 09 2019, 08:42 #386666
Thank you healyhatman, I feel like we're closer than ever haha : ) I adapted the PHP action to my fields, now the debugger correctly recognizes the array and returns only the fields I want. The only problem is now the CSV file only contains:

I checked if the naming is correct and everything seems to be just fine. Any ideas?
Debugger:
Array
(
[validate_fields2] => Array
(
[log] => Automatic validation enabled.
[var] => 1
)

[csv_data] => Array
(
[returned] => Array
(
[firstname] => FirstSample
[secondname] => SecondSample
)

[var] => Array
(
[firstname] => FirstSample
[secondname] => SecondSample
)

)
)
Attachments
CSVaction.PNG
CSVaction.PNG
(26.58 KiB)
90 Downloads/Views
CSVdata.PNG
CSVdata.PNG
(15.87 KiB)
85 Downloads/Views
CSVaction.PNG
CSVaction.PNG
(26.58 KiB)
91 Downloads/Views
CSVaction.PNG
CSVaction.PNG
(26.58 KiB)
90 Downloads/Views
CSVdata.PNG
CSVdata.PNG
(15.87 KiB)
90 Downloads/Views
admin 27
May 11 2019, 21:12 #386792
It should be:
return [["first_field_name" => $this->data("first_field_you_want"), "second_field_name" => $this->data("second_field_you_want")]];
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
admin 27
May 11 2019, 21:15 #386793
You can also use a "Data builder" action, add as many values as you need, they should be in this format:
Name: csv.0.title
Value: {data:field_name}
Then use {var:csv} as the data provider in the CSV action.
Best regards
Max
If your main question got answered then please mark the answer using the button!
Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!