I have a form that users can use to submit a report. As one of the fields is a text area where they can place quite a long text, I would like to insert a function that autosaves the entry every minute or so, but I'm not sure about the principles behind this.
the solution I can think of is:
- Autosave the current entry in the database as a version (eg. Entry_id = 1, Version = 1, Visibility = FALSE)
- After 1 minute, autosave again as Entry_id = 1, Version = 2, Visibility = FALSE)
- Keep repeating the above until either:
- User presses "SAVE". In that case, change the visibility of the last version to TRUE, and remove all other versions (all entries where entry_id == 1 and Visibility == FALSE)
- User chooses not to save ("DISCARD"). In this case I remove all entries where entry_id == 1 and visibility == FALSE
two considerations:
- The above should also work well if the customers is editing an existing entry.
- I can't use entry_id as primary key anymore
This seems to work in my mind but I'm wondering if I'm using a very convoluted process, and there is a better one?
Thanks, P