FormIt Integration Options: Make Form Submissions Easily Accessible to Client Only

This looks good and great effort, but does it limit the output to the user’s own forms and no other forms? That might not be needed but I thought it was…

Let’s get some OP feedback

Ahh. Good point. You could always write a JSON where statement for the &where param. Something like {"name":"client_form_name"} should work.

(Not tested)

1 Like

Thank you for this very helpful feedback. The person I am doing this for did ask for a google spreadsheet or something similar. I think RowBoat is the solution I was searching for. I really appreciate the recommendations and tips for implementing. I was working with FormItLoadSavedForm last night, but was not able to get it to output the data onto a resource. I’ll give RowBoat a try and post results later this morning.

2 Likes

Pls let us know if there are multiple users of your site that you want to give access to, or just one client of the site? If its just one client on the site then you won’t need to worry about limiting the output to only that users’ data

@inside-creative really excellent and detailed solution!

Getting close with this one. Safari on Mac now prompts for your approval to download a document. In the case of this TSV… there is not prompt, so no file was downloading. Attempted using Chrome… and voila! the TSV file downloaded. File was empty… but at least it’s downloading.

Best I can tell? Perhaps the table is incorrect. modx_formit_forms should be all forms correct? I only have one form, but perhaps I need to specify the form by name?

I can get a download, but no content.

Double check the error log. I suspect it could either be that the snippet call didn’t copy/ paste properly from the forums. Or that there’s an issue with the extra. Double check it’s installed :).

The table modx_formit_froms holds all forms saved by the formitSaveForm hook. But double check your DB to be sure - the error will tell you if it can’t find the table with that name.

The extra docs are here https://docs.modx.com/extras/revo/rowboat/rowboat.rowboat. Shows you what you can do with Rowboat. Might help you debut further.

Also, for dev purposes it might be easy to change the content type back to HTML, that way you can see the output directly in the webpage without having to keep downloading a file.

— another side note. Make sure your using the empty template for the resource.

A bit of success. Name of formit forms table is different in latest MODx. System Info Database revealed name as modxvs_formit_forms
Mac Safari displays the content within the browser instead of downloading a file.
Chrome downloads to .tsv file

Content in both is messy though. Not so user friendly at the moment, but feel as though it’s very close to working.

Content could be messy if the tsv chunk isn’t formatted correctly. I’ve found I actually have to create the file in an IDE, then regex find and replace all spaces (\s) with tabs (\t). If you write the placeholders in your IDE with one space between (or use a newline for readability just replace (\n) instead) then find replace it should format tabs properly.

I’ve been able to clean up but still messy. If I export CSV from formit, the file opens up with a header row containing the form labels and content follows in the rows and cells below.

With RowBoat, the content is identical to how it’s displayed within the manger. At least in the manager, the labels are bold… and content regular weight, so visually easy to review. Not so much after download and viewing in Numbers or Excel.

I may give CSV a go and see it that gets me closer to have formit exports the CSV.

You’ll need to add in the header rows to the actual resource. Once you’ve called the data into Google sheets you can make the header row bold.

As for the values. They are being presented in JSON format. Might want to look at writing a snippet that decodes JSON to array then for each over the array outputting the data in a more readable format

Glad you got it working. Let us know how you get on.

1 Like

Thank you for your feedback, and encouragement. I don’t think I fully understand your response. Add header rows?.. as in building an HTML table and allow my css to format the headers? Or am I need to create a chunk with the header rows. Sorry… been away from MODx for a while here and trying to get back in the saddle. Each form submission is on it’s own line, which is great. Where is gets confusing is that the entire cell for values contains the header label (i.e first_name) following by the value, etc, and so on. I’m continuing to work with this… might experiment with CSV format for the resource too. As well… I wonder if FormIt has a method for doing this.

1 Like

What I believe @inside-creative was saying is that the data is encrypted and he didn’t know how to decrypt it.

Try to explain what the problem is now in terms of the output.

I also wonder if there could be an easier way now that we have been mulling on this for awhile…can formit simply produce each file and save it into a folder somewhere?

If formit automatically creates the file after submission and saves that file in some format, its trivial to output that list of files for download…

Maybe that’s no different than using Rowboat, I am not sure. Let’s focus in on what output you want and see if we can get it, before going on to alternate solutions.

The data exports. Safari though displays in the browser, while Chrome downloads the TSV. ==ImportFeed works terrific over at my google doc. [[+values]] though is displaying the same as it is in the FormIt Manager, which is tough to read. Working on JSON to decode, remove labels and put each item in it’s own cell.

1 Like

Awesome. Great to hear we’re on the right tracks. I’ll post a snippet you can use to decode the JSON later on today when I’ve got some time.

If you want to give the snippet a shot yourself have a look at https://docs.modx.com/xpdo/2.x/class-reference/xpdoobject/field-accessors/fromjson

Basically you want the snippet to read the JSON of the [[+value]] placeholder (either call the snippet directly Or you could write this as an output modifier), then foreach loop through the object to output a string as readable data. I can’t quite remember how to format the string correctly as any newline will trigger an error in your tsv file. I’ll work through an idea and post

1 Like

This is a terrific lead. Thank you so much for sending. I am working on this this morning. I had done some googling last night for decoding JSON and felt like I was going down a rabbit hole.

1 Like

Ok, so i’ve been working on a simple snippet that will handle the conversion to CSV for you. It’s not elegant and full of holes, but it will do the job for you. Create a new snippet and call it in your resource (blank template with richtext false). Best to use CSV content type for the resource, but you can use HTML, either way =ImportFeed will work on both.

You’ll need to update the table name to match yours ( modxvs_formit_forms)
Also note that this only works for non-encrypted forms… i’ll continue working on getting a decrypt to work as it may help someone else.

1 Like

Got it to load. I removed the explanation mark from the snippet call. Two columns are results from radio buttons… essentially Yes or No is the available response. Those are populated with the word “Array”. I thought there was a cell that contained both first and last name, but it turns out that field was for the user to insert another persons first and last name in a single field — so all good there. This is awesome. Thank you.

2 Likes

No worries. Glad you got it to work :smiley:

When I get sometime I’ll see if I can hook into FormIts Decrypt Class to a version of the above can be used with encrypted forms.

On a side note, I highly recommend you find a way to restrict access to the resource. Last thing you want is personal data being held on a publicly accessible URL. You can mitigate this by giving the alias a random string i.e. 706b16b2fb732ab6079a10fea61d078b or use a snippet like below…

<?php 

$aKey = "706b16b2fb732ab6079a10fea61d078b";

if( !isset($_GET['key']) && $_GET['key'] != $aKey ) {
  $modx->sendUnauthorizedPage();
}

Add this snippet to the top of your resource page, then access the data by visiting https://yoursite.com/data.csv?key=706b16b2fb732ab6079a10fea61d078b

NOTE: The above code hasn’t been tested and there is probably a better way of doing it. I just want to give you something more to think about :smiley:

1 Like

Thank you so much for your help on this. I was kind of concerned about personal data and the public aspect. The random key idea is perfect.

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.