[Flask] Is there a way to periodically save form data without requiring the user to click on a button?

Daniel Watrous daniel.watrous at Trinet.com
Thu Apr 23 07:43:33 EDT 2020


P,

There are a few patterns that could work for this, but none of them are specific to flask.

  1.  If the form can be tied to an existing user account, you could cache the form details in a staging table. This could be done periodically as they are providing data. If they are unable to complete the forms, they can simply login later (from anywhere) and resume editing the forms.
  2.  If the session cannot be tied to a user, you might be able to do a check in JavaScript to see if the session has expired. If it has, the login process can be done in a pop-over that doesn’t disturb the contents of the forms.
  3.  You could indicate that the user has a limited time session and must complete the form in that amount of time. If they don’t, you can reset the form and have them start fresh when they have that amount of time.

There can obviously be variations on the above. Notice that the first two just have to do with caching the user’s partial response. There are a lot of ways to do this, both on the backend and on the client side.

Daniel

From: Flask <flask-bounces+daniel.watrous=trinet.com at python.org> on behalf of CCP Dragonedge <ccp at drsb.com.my>
Date: Thursday, April 23, 2020 at 2:47 AM
To: flask <flask at python.org>
Subject: [Flask] Is there a way to periodically save form data without requiring the user to click on a button?

WARNING: Do not click links or open attachments unless you recognize the source of the email and know the contents are safe.
Hi,

Let's say I have 10 input fields on a form. The user has input data into four or five of them. Before he completes, he is called away from his or her desk - for a long time (eg meetings, phone call, etc).

Let's assume that the user can't click on the Submit button yet because all of the fields haven't been input. So, the record isn't saved...

Is there a way for Flask to save it on the client side? I read about Flask-Socketio, but that seems kind of overkill.

Or is this outside the scope of Flask, and in the realm of Javascript? I found out about HTML5 Local Storage (or WebStorage). To my understanding, however, that's in Javascript, so then AJAX gets involved if I want to pass the saved value back to Flask, right?

p
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20200423/0e7389c5/attachment.html>


More information about the Flask mailing list