Reason

Due to some requirements I need to have multiple webform_submission drafts stored per user. This way, a user can jump from one draft to another at different points in time.

Problem

Upon loading a webform draft, loadDraft() resets the query results array to the first item as seen here:

return $this->load(reset($entity_ids));

Solution

I need to be able to pass in a condition, for example a sid or a token to the loadDraft() query so it returns the correct draft.

My approach was to add a 'draft_conditions' webform setting defined as a associative array of conditions (simple equivalence conditions) and iterate on these in the loadDraft function.

Maybe there is a better way to do this but it satisfies my use case.

Thoughts, suggestions?

Patch incoming.

Comments

ptsimard created an issue. See original summary.

ptsimard’s picture

Status: Active » Needs review
StatusFileSize
new723 bytes
jrockowitz’s picture

I think there is way to get 'view previous submissions' to support 'view previous drafts'.

There would definitely have to be a new setting for 'Allow multiple drafts' (draft_multiple) which would disable the autoloading of the previous draft and link to the multiple previously saved drafts.

This is not a lot of work but not something that is on my immediate roadmap. This feature would definitely require some tests.

jase-alexander’s picture

Would love to see this implemented for the reporting system I am working on.

Currently I have a check box on each submission to mark a entry as complete and do not allow the user to save as a draft.
Obviously not ideal.

jrockowitz’s picture

  • jrockowitz committed 5aa271b on 2856472-multiple-drafts
    Issue #2856472: Allow multiple drafts per users.
    

  • jrockowitz committed 686a2d9 on 2856472-multiple-drafts
    Issue #2856472: Allow multiple drafts per users.
    
jrockowitz’s picture

StatusFileSize
new104.65 KB

The attached patch adds 'Allow users to save multiple drafts.' to webform settings which permits multiple drafts to be saved, restored, and submitted.

The patch still needs some test coverage.

Status: Needs review » Needs work

The last submitted patch, 8: allow_multiple_drafts-2856472-8.patch, failed testing.

  • jrockowitz committed 4521af9 on 2856472-multiple-drafts
    Issue #2856472 by ptsimard, jrockowitz: Allow multiple drafts per users
    
jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new105.04 KB

  • jrockowitz committed 40f920c on 2856472-multiple-drafts
    Issue #2856472 by ptsimard, jrockowitz: Allow multiple drafts per users...
  • jrockowitz committed a07ba8f on 2856472-multiple-drafts
    Issue #2856472 by ptsimard, jrockowitz: Allow multiple drafts per users...
jrockowitz’s picture

StatusFileSize
new128.26 KB

  • jrockowitz committed fabc4c1 on 2856472-multiple-drafts
    Issue #2856472 by ptsimard, jrockowitz: Allow multiple drafts per users...

  • jrockowitz committed b9d2ff4 on 8.x-5.x
    Issue #2856472 by jrockowitz, ptsimard: Allow multiple drafts per users
    
jrockowitz’s picture

Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

jmunger’s picture

Are there any plans to get this working in Drupal 7?

jrockowitz’s picture

Probably not but you can create new issue for Drupal 7.