Form plugin data output

I need to output the form plugin data in csv format (comma-separated), and always append new data to the file so only one file gets created. Any clues as to how would I go about doing this?

By now I’ve managed to comment out the date portion of the filename in form.php so everything gets written to the same file. Now I just need to figure out how to append :smiley:


Forms supports an operation method (unfortunately not documented yet). You can use

    filename: csvdata.txt
    operation: add
    body: "{% include 'forms/data.txt.twig' %}"

to append your data to the file csvdata.txt. I’m using the Twig template for textual representation here, but you can use any other Twig template (in your case suited to output CSV data).

Marvellous, thanks, that works great!

Btw I bumped into a strange problem with MAMP where after I edit the Twig template for CSV data output (probably causing errors) Apache will stall after hitting “Submit” on the form and stops loading the next page. Data gets saved in the file but “Thank you!” page won’t load on localhost. Clearing caches on Grav and MAMP won’t fix it, so now I’m stuck editing on FTP.

I noticed something with operation: add: after adding that, body: gets ignored and the resulting file contents get rendered using the default template (but not the ones in forms/ or forms/default/ folders.) Any ideas how to fix that?

Please add a report of the issue on the Form plugin repo, thanks!