Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I press the previous page button to return to page 1 of the form, then return to page 2, the following messages appear:
Notice: Undefined index: submitted in webform_submission_create() (line 56 of /home/content/74/7802874/html/dp/sites/all/modules/webform/includes/webform.submissions.inc).
Warning: Invalid argument supplied for foreach() in webform_submission_data() (line 24 of /home/content/74/7802874/html/dp/sites/all/modules/webform/includes/webform.submissions.inc).
Comment | File | Size | Author |
---|---|---|---|
#15 | webform-webform_submission_create_notices-2544990-15.patch | 3.17 KB | DanChadwick |
#4 | Screenshot.png | 564.34 KB | vitalijus.trainys@gmail.com |
Comments
Comment #1
Jlightning CreditAttribution: Jlightning commentedComment #2
DanChadwick CreditAttribution: DanChadwick commentedI can't reproduce this using the latest dev. I tried both with and without the Automatically Save Drafts Between Pages option.
I suspect that some other module is modifying the form. You'll have to debug to see what's going on. If you do find that there is a bug with Webform, please re-open with more information.
I suggest you start by disabling all webform-related modules other than webform.
Also, a stack trace to see which caller of webform_submission_create is the problem would help.
Comment #3
Jlightning CreditAttribution: Jlightning commentedThanks Dan. I'm in the process of developing a complicated form. I have a timetable to meet. So I can't stop my development to do as you suggested. I thought that the error would be easily reproducible. Since it is not, the best procedure for me to follow is to use older versions of both form builder and Webform modules, both of which have error issues with the current versions. I know that it isn't good, since there have been security updates since the versions that I am using. The versions that I'm using are:
Webform 7.x-4.0
Form Builder 7.x-1.6.
Neither one has error issues.
I'm taking the risk, since the issues with both modules have been causing problems every time I tried to upgrade. I need to meet the timetable for project completion.
Comment #4
vitalijus.trainys@gmail.com CreditAttribution: vitalijus.trainys@gmail.com as a volunteer commentedSame behavior, same issue:
Notice: Undefined index: submitted in webform_submission_create() (line 56 of /var/www/develop.lva.lt/drupal/sites/sgk.lsmuni.lt/modules/webform/includes/webform.submissions.inc).
Warning: Invalid argument supplied for foreach() in webform_submission_data() (line 24 of /var/www/develop.lva.lt/drupal/sites/sgk.lsmuni.lt/modules/webform/includes/webform.submissions.inc).
Steps:
fill webform's fields in page 1
press "Next ..."
fill webform's fields in page 2
press "Next ...", then "Previous ..."
press "Next ...". Ooops, issue.
Edited:
I eliminate those warnings by adding some lines to function webform_submission_create:
Comment #5
sjekoken CreditAttribution: sjekoken as a volunteer commentedI'm having this same issue on an intranet site I'm developing and the error is strangely inconsistent. The group of webforms have almost identical components set up in an identical fashion, but the error is only kicked out on two of six webforms.
The only reason I even did multiple webforms was to keep the data separate by category, but the categories all require the same components. (for example, if you had one webform collecting info regarding "cars" and a different webform for collecting info regarding "trucks")
They are all styled identically as follows:
Start
CID1 = A simple intro markup component,
CID2 = a simple number component for entering the number of items you want to enter (i.e. "How many cars do you have?")
Page 2
Fieldset 1 = "First Car"
Fieldset 2 = "Second Car"
Fieldset 3 = "Third Car"
Fieldset 4 = "Fourth Car"
Preview
Complete
Form settings allow blocks, save draft button, save on next page
Conditionals are
If CID2 > 0, Fieldset 1 Shown
If CID2 > 1, Fieldset 2 Shown
If CID3 > 1, Fieldset 3 Shown
If CID4 > 1, Fieldset 4 Shown
That's it in a nutshell, but the errors kick out when I proceed to page two in 2 of my 6 webforms ...
I have telephone, date popup, and structured text modules enabled, but none of these fields are used in the two webforms which are kicking out the errors and the webforms where they are used are not kicking out any errors.
I ran cron, updated, erased cache, uninstalled rules and other modules that are touchy with webforms, but the errors are still there.
Comment #6
sjekoken CreditAttribution: sjekoken as a volunteer commentedBTW, I meant to write that the conditionals are ...
If CID2 >= 1, Fieldset 1 Shown
If CID2 >= 2, Fieldset 2 Shown
If CID3 >= 3, Fieldset 3 Shown
If CID4 >= 4, Fieldset 4 Shown
Comment #7
DanChadwick CreditAttribution: DanChadwick commentedFirst, disable those other modules to validate they they aren't causing the issue.
Second, removing conditionals one at a time to see if one or more is relevant.
Basically narrow down the circumstances until you can diagnose why some of your webform have the issue and others don't.
Or hire a developer to install a debugger, put a break point on the offending line and get a stack trace and explanation. I don't see any other way I can help from afar.
Comment #8
sjekoken CreditAttribution: sjekoken as a volunteer commentedMy errors disappeared when I removed the page breaks, but I thought the inconsistency was interesting. All 6 webforms had a "how many" field on page one and conditionals set to show that number of fieldsets on page two, but only two of the webforms would show the error while the other four were fine. Perhaps it had something to do with whether I set the page break before I set the conditionals? That factor may have differed between the webforms, but I'm not sure. All I know is that updating didn't fix the two webforms with the undefined index error, only removing the page breaks did.
Comment #9
DanChadwick CreditAttribution: DanChadwick commented@sjekoken -- can you start with a new webform node and no other webform-related modules enabled and provide the simplest instructions necessary to reproduce the issue?
Comment #10
vitalijus.trainys@gmail.com CreditAttribution: vitalijus.trainys@gmail.com as a volunteer commentedIt seems (krum exposing it) like function webform_submission_create() is calling twice on navigate to back/next webform's page.
In first call, it comes with !isset( $form_state['values']['submitted']) and generates warnings, because variable $data is not set. In second call, the variable $form_state['values']['submitted'] is filled in and provide a valid behavior of function. I think, a little patch, like
will eliminate a garbage warning... :). Not tested in other environment, different from project, on I'm working now. Sorry. :)
Comment #11
DanChadwick CreditAttribution: DanChadwick commented@vitalijus -- We need to figure out the root cause. We don't add tests to handle data that we know should be present. Instead we figure out why the data isn't present make make it present.
I do see an inconsistency in markup.inc, function _webform_render_markup_after_build():
$form_state['storage'] is tested, but $form_state is passed to webform_submission_create. However, I cannot create a situation where storage is set (i.e. the form has already been built once for a multi-page form) and yet $form_state['values']['submitted'] isn't also set.
Are you using some ajax on this page, perhaps? I need more data to help find the root cause.
Comment #12
vitalijus.trainys@gmail.com CreditAttribution: vitalijus.trainys@gmail.com as a volunteer commented@DanChadwick: no, I'm not using any Ajax calls :) & OK, I can debug or test function _webform_render_markup_after_build() and submit results. But later, because vacations, vacations :).
Comment #13
rickyjuneja CreditAttribution: rickyjuneja commentedThis message can be reproduced if save draft and preview pane is enabled. Once the user logs out at preview screen but does not submit and logs back this message appears.
Comment #14
DanChadwick CreditAttribution: DanChadwick commentedRe #13. Thanks for this. I've reproduced the issue, but it is unrelated to the markup issue above. I think we have two different causes. The #13 issue is caused as a regression to the code which resumes a draft at the highest saved draft page. webform_client_form sets $form_state['storage'] but doesn't set the ['values']['submitted'], which I think it should.
That still leaves the issue with markup components. The right values would be those calculated in webform_client_form's $input_values, but that isn't available easily in the webform component.
Comment #15
DanChadwick CreditAttribution: DanChadwick commentedThis patch makes two changes:
Both of these changes should both provide the correct values for tokens and avoid the PHP notices. I have tested all the relevant cases that I can think of, but additional testing would be welcome.
Committed to 7.x-4.x.
Comment #17
DanChadwick CreditAttribution: DanChadwick commentedPort to D8 needed.
Comment #18
MustangGB CreditAttribution: MustangGB commentedI just experienced and followed this issue today, 4 hours later Dan fixes it.
If only all issues were as easy/quick to solve :P
Comment #20
fenstratCommitted and pushed to 8.x-4.x.