Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Form plugin data output

Started by Muut Archive 10 years ago · 5 replies · 887 views
10 years ago

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?

10 years ago

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 :D

10 years ago

Hi,

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

TWIG
process:
  save: 
    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).

10 years ago

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.

10 years ago

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?

10 years ago

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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1361 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1122 9 years ago