Upload contents of a form to CSV

hyperlast 02 May, 2019
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  {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!
Max_admin 03 May, 2019
Hi,

Please check my post here



Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
hyperlast 08 May, 2019
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 08 May, 2019
Hi hyperlast,

Please check this post from the thread Max linked to.

Bob
hyperlast 08 May, 2019
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 09 May, 2019
return [ "first_field_name" => $this->data("first_field_you_want"), "second_field_name" => $this->data("second_field_you_want")];
hyperlast 09 May, 2019
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
                )

        )
)

​[file=12198]CSVaction.PNG[/file]
​[file=12199]CSVdata.PNG[/file]
Max_admin 11 May, 2019
It should be:
return [["first_field_name" => $this->data("first_field_you_want"), "second_field_name" => $this->data("second_field_you_want")]];
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 11 May, 2019
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, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.