Closed (won't fix)
Project:
Webform
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
19 Sep 2012 at 13:51 UTC
Updated:
3 Apr 2015 at 18:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
quicksketchCan you describe how you've set up your form with conditional rules? How does the upload field "not work"? Is the value lost? Or does it work but you get these errors?
Finally, this is probably fixed already in new conditionals system in the 4.x branch. We might not see a fix for 7.x-3.x if the new system has fixed this problem (and many others with the old conditionals) already.
Comment #2
tobiasbA really simple setup:
* page 1 a textfield
* page 2 a file component, which has a conditional rule e. g. the value of the textfield is "test".
Enter the value on page 1 and then try to upload a file on page2, which does not work.
Empty the conditional rule, upload works fine.
Comment #3
michellezeedru commentedI can verify that I'm seeing the same errors. My conditional rules are on the page break however, not the file field (i.e. I want this page skipped altogether based on answers on a previous field). When this is the case, I see the file field initially and can select a file for upload. The file uploads, but when the upload is complete, the field disappears off the screen. If I proceed to save, none of the data I entered in other fields on this page is not saved.
If I remove the conditions on the page break, the filefield works as expected.
When I check the recent longs, it seems these 3 errors occur each time this happens:
Notice: Undefined offset: 2 in webform_client_form() (line 1992 of /home/michell3/public_html/sites/all/modules/webform/webform.module).
Notice: Undefined index: guest_photo in file_ajax_upload() (line 271 of /home/michell3/public_html/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /home/michell3/public_html/modules/file/file.module).
Comment #4
jrichards1982 commentedI am experiencing the same issue. Page two display is a conditional of data on page one. These are the errors:
Notice: Undefined offset: 2 in webform_client_form() (line 1992 of /var/www/html/sites/all/modules/webform/webform.module).
Notice: Undefined index: testfile in file_ajax_upload() (line 265 of /var/www/html/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 274 of /var/www/html/modules/file/file.module).
Comment #5
valderama commentedsame problem here :/
edit: updating to webform 3.x dev and webform_conditional 1.x dev did _not_ help.
edit2: updating to webform 4.0 alpha did not help either.
edit3:
I guess the problem is that form_state['values']['submitted'] does not contain any data about data other then the upload field (which triggers a form rebuild).
Then, when the form is rebuilt, webform module cannot trigger the conditional correctly, as the data is missing.
Comment #6
valderama commentedI solved the problem by using $form_state['storage'] to override $form_state['values'] in the rule checking function:
Comment #7
valderama commentedHere is a patch against 7.x-3.x - I assume the crucial parts are the same as in 3.18, which is the version which I am working with.
Please review, thanks!
Walter
Comment #8
valderama commentedwrong naming of the patch file. Does not matter much, I guess. However, here is a new patch.
Comment #9
matglas86 commentedThis patch is working correctly. Helped us out with a client.
Comment #10
michellezeedru commentedConfirmed, the patch in #8 resolved my issue in #3. Thank you!
Comment #11
michellezeedru commentedEDIT (sorry for the initial sloppy and incorrect post):
I just updated to webform 7.x-4.0-alpha6, and I'm seeing the same error I reported in #3. By manually adding the patch in #8 the problem is resolved.
Comment #12
historysa commentedI have the same issue occuring for webform 7.x-4.0-alpha6 (getting the notices at the top of this post). I manually inserted the patch, yet the issue still occurs. I copied the missing lines into the module starting from the declaration of $conditional_component to the end of the if statement.
Is there something different that michellezeedru may have done?
Comment #13
quicksketchThis patch makes me very nervous, considering it changes one of the most central parts of Webform's processing code. Any more confirmations of this problem and the patch's solution would be welcome as people try this out. I'm a little hesitant about including it specifically for the 3.x branch, if the only impact is on users of Webform Conditional module.
Comment #14
tobiasbWhat is in
$form_state['values']['submitted']at the moment?Comment #15
quicksketchIt should be the values from the current page that is being submitted.
$form_state['storage']['submitted']should be the values from all pages merged together. We do some extensive manipulation around these values I believe, so just replacing one whole chunk of values with another manipulated set makes me nervous.Comment #16
jastraat commentedI'm seeing this same error with just using the conditionals included in the Webform 3.x branch - not the Webform Conditional module.
Comment #17
jastraat commentedI wouldn't suppose this is related?
https://drupal.org/node/1336212
Comment #18
liam morlandSeems to be a duplicate of this: #1794862: Uploading Files Produces Ajax Error. I put simple steps to reproduce the problem in that issue.
I am seeing this problem and am not using the Webform Conditionals module.
Comment #19
liam morlandComment #20
vinmassaro commentedSetting this back to 'Needs work'. We are seeing the problem with 7.x-4.0-alpha9. This particular webform uses conditionals and the patch in #8 doesn't fix the error when uploading an image to a file component.
Comment #21
spadxiii commentedI just updated to latest beta2 (2014-02-12) and can confirm that this issue is still there.
My test is a webform with the following components:
- select options with 2 values
- page break
- file upload
- textarea
Add conditions that shows the file upload for the first select option and the textarea for the second option.
After selecting the first option, submitting to the next page and then clicking the upload button, the file input disappears. This happens because of the conditional removing the field, because the value is not in the $input_values. By also using the form_state 'storage' values, the conditional finds the correct value and does not remove the file input.
Attached a patch with the code I used to fix the issue.
Comment #22
quicksketchThanks @SpadXIII! This looks much less likely to cause significant problems, and it's a lot easier to understand what's going on with a smaller scoped variable.
I can't see any problems with this patch or approach. In testing it functions as expected and all the tests are still passing. Let's try it out in a wider audience in the next beta release that I'm rolling today to fix other issues found in beta2.
Comment #24
fenstratNeeds porting to 8.x-4.x.
Comment #26
fenstratCommitted and pushed a072683 to 8.x-4.x. Thanks!
Comment #28
john_b commentedComment #29
fenstrat@John_B please don't blindly overwrite the OP. That is what the comment field is for.
For reference here is what was posted:
7.x-3.x is receiving bug fixes only, as this is a bug I'm assigning to @torotil as the 7.x-3.x branch maintainer.
Comment #30
danchadwick commentedThanks fenstrat. To clarify, the 7.x-3.x branch has a commitment to receive critical bug fixes, plus whatever bugs torotil sees fit to commit. Therefore this is now a task.
Upgrading to 7.x-4.x is always preferred, whenever possible.
Comment #31
john_b commentedSorry, I must have been tired,
Comment #32
torotil commented@John_B: I'm happy to look into this at one point. But I think that #8 is not the way to go: As stated in #13 replacing
$form_state['values']['submitted']with$form_state['storage']['submitted']might have side-effects that need to be thoroughly checked. Also there might be webform-based modules that rely on the current way those variables are handled. Thus I much prefer a more cautious patch.Comment #33
danchadwick commentedPutting this back to won't fix, since torotil isn't actively working on this. All 7.x-3.x non-critical bug fixes are at torotil's discretion.