2

I am using the Webform module to create a form. I've only just realised that the "Save draft"button is available only for authenticated users, which is a shame! Is there an easy way of making the "Save draft" button available for anonymous users as well?

1
  • 1
    save draft is available for authenticated users only as it can easily save value with uid. For anonymous users you cant keem track properly for the draft value. Still if you want to try you should try to store form values in $_SESSION and use it but after logged out the values will be lost.
    – j2r
    Mar 1, 2013 at 6:04

1 Answer 1

2

The condition is on line 1977 of webform.module.

You can remove the && $user != 0 condition, but the comment above is valid. Removing the anonymous user check allows the form state to be saved in the database, with uid=0 and a valid sid.

Removing the same anonymous user check on draft form retrieval, however, does not result in the active draft being returned to the anonymous user.

This functionality would require patching the webform module to allow storage of the $form_state in $_SESSION, or in a client-side cookie, which could be read as part of the draft form retrieval process. It would not be difficult to do, but would be a significant change in the webform module.

If you wish to pursue this, open a feature request in the Webform issue queue on Drupal.org, and message me with the link.

3
  • @Partick Kenny - I looked at webform_client_form_submit before I answered, and yes the form is saved. I just confirmed it - the draft from an anonymous user is saved in the database. The problem is the retrieval. I think prop_341 has a valid point. If an anonymous user partly fills in a form, then leaves the page for whatever reason, it would be good if the work he already did was preserved, at least for the duration of his current session. Maybe j2r is right. But all we would realy have to store in $_SESSION is the webform's sid. I think it is doable.
    – Triskelion
    Mar 1, 2013 at 6:56
  • Thanks guys. here is a feature request link: drupal.org/node/1932560 @Triskelion
    – prop_341
    Mar 3, 2013 at 22:27
  • I have added to the feature request. Let's see where we can go with this. @Patrick Kenny - Done :-)
    – Triskelion
    Mar 3, 2013 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.