After committing #226907: Patch adding save draft feature, default values do not work if a draft is saved and then resumed. To reproduce:

- Create a form with multiple pages.
- Give a default value to a component on the second page.
- Fill out the first page of the form, then click Save Draft.
- Now visit the second page of the form, note that the default values are not populated.

Default values still work on multipage forms as long as a draft is not used.

This problem extends from Webform's inconsistent storage of data. Sometimes we're working with values from $form_state['values'], sometimes we're working with a $submission variable. Worse yet we're actually using what was intended to be display-only functions to edit submissions or resume drafts. This issue may eventually be merged with #181077: Printable page for webform submissions, which also stems from this same set of problems.

Comments

quicksketch’s picture

Title: Default values do not work when resuming from drafts » Default values do not work when resuming from drafts (Component system refresh)
Status: Active » Needs review
StatusFileSize
new142.46 KB

Okay here's a take at this change, it's quite a large patch but mostly due to changes to PHPdoc and function signatures for consistency. The primary purpose of this patch is to make the _webform_render_[component]() function take a $value parameter so that we can use it for editing submissions. It also sets us up nicely for #181077: Printable page for webform submissions because the _webform_display_*() functions are no longer used for editing, meaning we can switch it to using theme functions and nice output fairly easily.

Ultimately though, we fix the initial problem that brought this all up: Saving as a draft was breaking default values.

quicksketch’s picture

StatusFileSize
new142.57 KB

I found that the "Table" results display was not working with the previous patch. This one fixes it as well as some more consistency fixes when referring to array keys ($value[0] instead of $value['0']).

quicksketch’s picture

Status: Needs review » Fixed

Committed. We'll probably still need to do a lot of re-factoring on the component system. We could either switch the component system to an actual hook system, or we could simply let other modules write components the exact same way Webform currently does, as suggested in #151603: Can I put options in a select field from a database query?.

Status: Fixed » Closed (fixed)

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

alextronic’s picture

Version: » 6.x-3.0-beta2

Hey quicksketch,

I have upgraded to 6.x-3.0-beta2 because I had a problem with the default values not being saved in drafts after applying the "Save Draft" patch in #226907: Patch adding save draft feature, and to corroborate afterwards that patch in #680960: Default values do not work when resuming from drafts (Component system refresh) wouldn't work for 6.x-2.9.

Now, I can tell you, I am not really convinced of the advances. Things I have noticed:

- the default values still are not saved (in my form, they all go back to default 0), so I really experience no step forward here.
- after saving draft, the form goes back to the first page, maybe it should stay where it was when saved, imho.
- after saving draft and reloading page, I get a "You have already submitted this form", but I never did so. Only saved it.
- Several fields are now displaced, like CSS were broken. This is the most annoying issue by far. See attached (components should align creating rows of 5 input fields each; now they are all scattered)

These 4 issues are way too much to deal with, specially at this point, so I am going to revert to 6.x-2.9, but the problem with the default values is a huge drawback, sorry to say, so I guess I'm stuck between branches, am I?

alextronic’s picture

StatusFileSize
new16.25 KB

Forgot to attach screenchot, sorry for the blur.

quicksketch’s picture

alextronic: Please open a new issue (or multiple) for your requests and reference this one.

quicksketch’s picture

Also: The above fixes are NOT in beta 2. You need to use the latest CVS version. I'm just about to release beta 3, so you can get these changes in that version.

alextronic’s picture

Thank you quicksketch.

alextronic’s picture

do you have an estimate release date for beta 3 ?

alextronic’s picture

Hi,

I have tried using beta 4 and I had to revert back to 2.9 because the issues I noticed with beta3 (on comment #5) still happen, and I will create issues for them as suggested.

However, when quicksketch talks in #8 about releasing beta 3...... is he referring to 6.x-3.0 branch, without the "beta"? I am in a "wait and pray" scenario and would be SO thankful to know an estimate date for the release of a version that can manage drafts and default values effectively.

Thanks so much for the hard work.

Alex.