Hi

I have upgraded webform to the webform 7.x-4.0-alpha6 to resolve the issue related to conditional webform module.

This is working fine as I expected but with the following notice when the user selects the condition "NO" but the email is received what I expected


Notice: Undefined index: info in webform_tokens() (line 137 of /var/www/sites/all/modules/webform/webform.tokens.inc).

I have a conditional field:

Do you have a car? - if yes the user has to enter the name of the car and when submitted the email contains

DO you have car : yes
Name : Honda Civic

_______

For the same field -Do you have a care?- IF no -there is no need to enter the name as it is not displayed and when submitted the email contains : the below is what I am expecting and I receive the same .No issues but after submitting the form when it goes to "Thank You Page" on the top of this page there is a Undefined Index Notice

DO you have car : No
Name :

Please do the needful.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Akshita’s picture

Can anyone look into this issue please?

quicksketch’s picture

I'm not sure what the cause of this issue is. It seems as though you may have some nested fields that are causing the issue with tokens. The key "info" missing isn't a hard-coded string on line 137, it looks like it's a variable. So I'm guessing you have a fieldset with a key of "info"... not entirely sure though. If the notice isn't causing any trouble, in the mean time you can surpress notices under the "Error Reporting" admin page by showing only Warnings and Errors.

To help with this problem, it would be beneficial if you could start with a brand new form with just a single file on it and see if it is reproducible. Right now it's hard to tell what the problem is if it's not something that I can reproduce.

nflowers1228’s picture

I'm having a similar problem and might be able to give more details to how it's happening for me.

I am using tokens in my Form settings to create the confirmation page. My form has many conditional fields which means that some fields are left blank unless they are relevant to the previous selection.

Example:
Option list "Is this an existing site" Options Yes/No
If No is selected, then "Existing Site URL" field does not display.

I put the the following token in the confirmation page which included the nesting of the Fieldsets (site_information is the fieldset):

[submission:values:site_information:existing_site_url]

When I submit it, I get the following error:

Notice: Undefined index: existing_site_url in webform_tokens() (line 137 of /data01/d7/dev.yalesites.yale.edu/sites/all/modules/contrib/webform/webform.tokens.inc).

I have several conditional fields that I want to display in the confirmation page. When I use just [submission:values] to display all values, they all show up in a big paragraph without any line breaks so each field is on a separate line.

Hope this provides more clarity.

Akshita’s picture

#3

I am also having the same issue . But for now as suggested by #2 disabled the Notices on configuration page.-It is a work around for now.

quicksketch’s picture

My form has many conditional fields which means that some fields are left blank unless they are relevant to the previous selection.

Thanks @nflowers1228 for the information! So it sounds like the nesting isn't the problem, it's the hidden fields that are causing the notices. That seems like it should be relatively easy to fix.

masdzen’s picture

I had the same problem. and I removed the checkmark from the checkbox "extra private" in the webform field config and worked out!

chyatt’s picture

I have a similar problem. e.g.:

Notice: Undefined index: contact in webform_tokens() (line 137 of /var/www/html/mysite/sites/mysite/modules/webform/webform.tokens.inc).
... 10 more ....
Notice: Undefined index: project_request_details in webform_tokens() (line 137 of /var/www/html/mysite/sites/mysite/modules/webform/webform.tokens.inc).

Any of the tokens listed in the error message are not included in the text of the email that gets sent.

I noticed that the tokens listed in the error messages corresponded directly to tokens not selected in the "Included e-mail values" section on the "Edit e-mail settings" form. By selecting (and therefore enabling) those tokens, the errors were resolved and the email text now includes them.

Since the "Included e-mail values" section is collapsed by default, I wonder if this solution might work for those of you also seeing this?

Stupid question: Why do we even need that Included e-mail values" section?

C

TimG1’s picture

Hi All,

I'm getting the same error. Here's my example.

[ ] Are you an alumni?

Graduation year ________
Name at graduation _______

"Graduation year" and "Name at graduation" only appear if "Are you an alumni" is checked using conditional webform fields.

I also have these fields emailed to a staff member using tokens.

[submission:values:graduation_year:nolabel]
[submission:values:graduation_name:nolabel]

Submission produces no errors if "Are you an alumni" is checked and graduation year/name are filled out. Email gets the submitted value fine.

If "Are you an alumni" is not checked I still get the email fine, but the following errors are produced.

  • Notice: Undefined index: graduation_year in webform_tokens() (line 137 of \sites\all\modules\contrib\webform\webform.tokens.inc).
  • Notice: Undefined index: graduation_name in webform_tokens() (line 137 of \sites\all\modules\contrib\webform\webform.tokens.inc).

If I remove the tokens from my email that gets sent (but keep the webform fields as is) the error messages go away if submit with "Are you an alumni" unchecked.

None of my fields have the [ ] private checkbox checked.

Drupal 7.17
Webform 7.x-4.0-alpha6
Webform Tokens 7.x-1.1
Token 7.x-1.4

Thanks for reading,
-Tim

romaingar’s picture

Ok, i'have the same issue, BUT if i add a simple
dpm($display_element);
just before the foreach line 137 of \sites\all\modules\contrib\webform\webform.tokens.inc
the notice disapear....
the dsm is not displayed and the value of the fields as well...

it's very strange isn't it ?

if ($match) {
              // Drill down into the renderable to find the element.
              $display_element = $submission_renderable;
              dpm($display_element);
              foreach ($parents as $parent) {

                $display_element = $display_element[$parent];
              }
              // Remove theme wrappers for the nolabel modifier.
              if ($modifier === 'nolabel') {
                $display_element['#theme_wrappers'] = array();
              }
              $replacements[$original] = render($display_element);
              break;
            }
John Pitcairn’s picture

Yep, getting this too on webforms upgraded from 3.x.

The field token that is throwing the error for me is [submissions:values:phone:nolabel]. The field is a simple mandatory text field, field key is correct, and the field is not private or hidden.

John Pitcairn’s picture

Interesting. If I remove that token from the email body, and from the "included email values", and flush all caches, I still get the error.

Argh. I was altering the wrong form.

Adding the required token to "included email values" has fixed it here.

hefterbrumi’s picture

The behavior of this error for me is like that:

If a field is hidden due to the condition (and obviously not filled in) then it throws the error. If its not hidden because of the condition but left empty or filled in, it wont throw any errors. I tried to play around with the settings with no avail.

Some of them are in a fieldset and some of that not.

I am using a custom template for email.

"Adding the required token to "included email values" has fixed it here" in the previous comment does not make any sense for me. Everything is ticked there for me.

jreashor’s picture

This fixed the issue for me.

              foreach ($parents as $parent) {
                if (isset($display_element[$parent])) {
                  $display_element = $display_element[$parent];
                } else {
                  unset($display_element);
                }
              }
p_stampy’s picture

Thanks!

#13 worked for us too.

Roensby’s picture

This issue is happening in 7.x-4.0-beta1 too

Using tokens on the confirmation page for conditional components that haven't been filled out by the user triggers the "Notice: Undefined index" error.

penone’s picture

Issue summary: View changes

Can someone tell me where to put #13?

Thanks.

quicksketch’s picture

Status: Active » Fixed
FileSize
1.13 KB

Thanks for the suggestion @jreashor. I've revised slightly because just setting $display_element to FALSE could result in PHP notices later down in the same function. I've committed this patch which is nearly identical, but skips the remainder of the function if $display_element is empty.

A new release should be coming out tomorrow, this fix will be included.

Status: Fixed » Closed (fixed)

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

fenstrat’s picture

Version: 7.x-4.0-alpha6 » 8.x-4.x-dev
Assigned: Unassigned » fenstrat
Status: Closed (fixed) » Patch (to be ported)

Needs to be ported to 8.x-4.x.

  • Commit 0644c6a on 8.x-4.x authored by quicksketch, committed by fenstrat:
    Issue #1800212 by quicksketch | Akshita: Notice: Undefined index: info...
fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-4.0-alpha6
Assigned: fenstrat » Unassigned
Status: Patch (to be ported) » Fixed

Committed 3915d99 to 8.x-4.x.

Status: Fixed » Closed (fixed)

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