Reviewed & tested by the community
Project:
Autosave Form
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Apr 2017 at 09:56 UTC
Updated:
11 May 2026 at 17:45 UTC
Jump to comment: Most recent
Comments
Comment #2
grienauer+1 for this feature from me.
Is there an idea if this could be a possibility/feature which could be implemented?
Comment #3
mostepaniukvmWe are currently discussing a possible fallback approach for cases where autosave cannot reach the server.
The idea would be to implement an optional feature in the module.
Backup process change:
- if an AJAX request fails, store the same outgoing payload in localStorage
- continue autosaving while offline and keep updating the localStorage backup
Restore process change
- before showing the recovery dialog, also check whether a newer backup exists in localStorage
- if a backup exists in localStorage and the user chooses to restore it, first send that backup to the server, then use it to reload the form
Does this sound like a reasonable direction, or are there known limitations that would make this approach unreliable?
Comment #5
jvdkolk commentedI think
<input type="file" />will be a problem: Its value will be a read-only reference to the file (because of security), so you cannot use it to restore its value (source: https://developer.mozilla.org/en-US/docs/Web/API/FileList).Folks on StackOverflow read the file and store it as a base64 encoded string (e.g. https://stackoverflow.com/questions/75479585/how-to-save-an-image-input-...), but localStorage has a 5 Mb limit on the amount of data it can store (https://developer.mozilla.org/en-US/docs/Web/API/Storage_API/Storage_quo...)
One could argue though, that the referenced file will not get lost when there is no internet, as it is on the user's computer.
Comment #6
jvdkolk commentedWhat about https://www.drupal.org/project/auto_save_form?
Comment #7
mostepaniukvmIn the PR, I added an implementation as an optional feature of the module that can be enabled on the settings page.
In case of an AJAX error, it will continue saving backups to localStorage. Once the server becomes reachable and the user reloads the form, it will try to restore the latest backup from localStorage.
The difference compared to the auto_save_form module is that the restore does not happen on the front end. When the user chooses to restore, it sends data from localStorage to the back end and continues with the existing restore procedure.
Comment #8
a.milkovskyTested the MR. It works great!