If the user successfully submits the form and then comes back later, autosave should not present the saved version of the form. Since their work on the form was not interrupted, it is confusing to see the autosaved values, as though their work had been interrupted.

This patch adds a submit handler to the form, so that on successful submit, the appropriate values are blown out of the autosaved_forms table.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

galaxor’s picture

FileSize
24.65 KB

So I finally noticed that you already had a solution in place that was using hook_nodeapi('presave'). That is a good idea -- I switched my version to use presave instead of submit.

Still, I found that, even with my patch, there were still cases where this problem was cropping up. I have an alternative solution now, which seems to work better.

I added a 'status' column to the autosaved_forms table. When the form is first built and sent out, there will be no row in the autosaved_forms table. When the first autosave comes in, it'll add the row, and the status will be 'editing'. When new autosaves come in, they are saved only if the status column is not 'submitted'. Once the user successfully submits the form, the presave hook will change the status to 'submitted'. Any autosaves that come later will be ignored. When the user edits again, and that form is rebuilt, then we will delete from the table all the rows where status is submitted, and it matches the form_id, path, and user.

But if the user never edits the form again, we will have a bunch of stale 'submitted' rows in the database. So I made a cron hook that will delete the ones that are over an hour old.

chinita7’s picture

Thanks for the patch.
I tried the dev version with patch #0 but didn't work for me. I would try #1 also but my site has problem with jquery UI module so not untill solve the problem with jquey UI.

liquidcms’s picture

i am pretty sure this works without your patch; can you define a use case that shows it busted?

liquidcms’s picture

Status: Needs review » Postponed (maintainer needs more info)
Crell’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)