formtools / core

The Form Tools Core.
https://formtools.org
207 stars 78 forks source link

Only create db entry upon initial form submission (no null rows) #694

Open zenfits opened 4 years ago

zenfits commented 4 years ago

FT 3.0.20-20191109 Form created using FormBuilder and not using API for now.

Works great! But I have a need for submissions with gapless, continuous submission_id which would be the case if the database entries were only created upon actually submitting the initial instance of the completed form (subsequent form updates/deletes would use the now-existent submission_id).

As it stands, the db entry is created just by visiting the web page with submission_date set to the timestamp of the initial page load. As we know, this new (mostly null) entry is filled as the form's page tabs are filled/edited, then when finally submitted the is_finalized is flipped to yes and the submission_date remains set to the timestamp of initial page load and last_modified_date is set to the actual submission finalized timestamp.

I see that the code change for this is likely somewhere in Submissions.class.php, but I can't really see what to change such that nothing else is affected.

This topic was visited in https://forums.formtools.org/archive/index.php?thread-198.html but that was for an earlier version of FT and the solution does not apply now. Ben suggested calling ft_api_delete_unfinalized_submissions, but I would much rather see continuous, gapless IDs.

Perhaps switching to the api method would make this effort easier or even doable. Perhaps using the cache to create a temp table for form filling that copies to the db upon submission? But that might create issues in the case of multiple concurrent visitors.

Thanks for any guidance.