Here is the notices (20 of the same ones) that i was getting on every webform submission:

Notice: Undefined index: in _webform_client_form_submit_flatten() (line 2805 of /home/html/sites/all/modules/webform/webform.module).

I looked in the code on line 2805:

we are using

$node->webform['components'][$cid]['type']

without checking if its set first... We need to add one more condition level:


isset($node->webform['components'][$cid]['type'])

this solved the problem for me... maybe someone could commit this to the future releases...

CommentFileSizeAuthor
#14 cid.patch938 bytesdarksnow
#10 node-export[156](1-nodes).1356645604.zip5.3 KBGCP
#8 node-export[41](1-nodes).1352471573.zip10.1 KBAnonymous (not verified)

Comments

Anonymous’s picture

Version: 7.x-4.0-alpha4 » 7.x-4.0-alpha6
Priority: Normal » Major

Could anyone look at this, i reported this in alpha 4 and its still here in alpha 6 currently the error is saying on line 2893

quicksketch’s picture

Priority: Major » Normal

Thanks for the report. I haven't been able to confirm this problem which is why it hasn't been addressed. Could you provide steps to reproduce the problem? Does this happen on new webform nodes, or only a certain Webform in particular?

Tobias Jonch’s picture

I would consider this of major priority as well (mainly because I get it too ;-)

I can't provide an exact way to replicate, but for me it deals with certain pages of the same webform.

At first I got an error like this; Undefined index: submitted in webform_client_form_validate()
(looks like there's another issue for this)

I figured I'd try deleting the components on that page and create them again, but then I got the error reported here.

Hope it helps you help me! ;-)

Otherwise a truly great module!!

quicksketch’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks Tobias, that makes a start but I still have no idea how to reproduce this problem. Sounds like it *is* specific to one particular Webform in your case, which means there's probably some set of steps you have to do to get the Webform into that state where it starts causing trouble. I'd like to look into this problem, but I can't fix it if I can't see it.

Tobias Jonch’s picture

Can I somehow export the webform I've made, share it with you?

Would it help to see the webpage itself?
It's for a customer, so I don't want to make the url public - but I don't see any harm in sending it to just you.

Also, I have found that once I have ticked a choice on the page in question (answer required), then go to the next page and back again, the error isn't there. hm. I guess it only validates the form going forward.

-Tobias

PS: I should mention that I'm back to my original error msg:
Notice: Undefined index: submitted in webform_client_form_validate() (line 2510 of ..... webform/webform.module).

quicksketch’s picture

You can export the node with Node Export module and send me the export. That would be more helpful to me than seeing your site, as I'll be able to debug it locally.

arodier74’s picture

Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Active

Thanks for this module, it is great to use, and powerful enough for most of the cases.

However, I have the same error, and I think it's major as well. Here the modification I have made in my environment to fix the error:

<?php
$new_values = _webform_client_form_submit_flatten($form['#node'], isset($form_state['values']['submitted']) ? $form_state['values']['submitted'] : []);
?>

Beside that, I think that 4k lines of code in the same file is a little bit too much, and some code should be factorised in many sub files.

Anonymous’s picture

StatusFileSize
new10.1 KB

Hi please see attached zip it contains my node export file where i get the error

Anonymous’s picture

any update?

GCP’s picture

StatusFileSize
new5.3 KB

We're also getting this error. We're using a new module called Webform View, and when I disabled that module, the error stopped. Since others without Webform View are getting this error, I thought it would be more helpful here than in that module's queue, and might help in reproducing it. I'm attaching a Node Export of the webform, in case it's helpful.

dazweeja’s picture

Also seeing this error and can't reproduce consistently.

However, the error message has no index (after the ':') so it looks to me like $cid is undefined, which means that 'webform_get_cid($node, $form_key, $parent);' on the previous line did not return a value. I don't know under what circumstances webform_get_cid() does not return a value (I suspect it's related to the $parent parameter), but to use the result of a function that doesn't necessarily return a value as an array index looks to me like fragile code.

strae’s picture

Hi all, im using a different version (7.x-3.18) of this module, but i noticed this problem if I try to move elements from a fieldset to another.

In my module_form_[FORMID]_alter() i have something like:

// Move the captcha element
  if(isset($form['captcha']))
  {
      $form['submitted']['fieldset_1']['sub_fieldset_1']['captcha'] = $form['captcha'];
      unset($form['captcha']);
  }

The validation works good, but I always get this error:
Notice: Undefined index: in webform_submission_data() (line 26 of /sites/all/modules/webform/includes/webform.submissions.inc).

But if i move the actions element:

// Move the action buttons
  if(isset($form['actions']))
  {
      $form['submitted']['fieldset_1']['sub_fieldset_1']['actions'] = $form['actions'];
      unset($form['actions]);
  }

The error is different:
Notice: Undefined index: in _webform_client_form_submit_flatten() (line 2607 of /sites/all/modules/webform/webform.module).
and the form doesnt get validated (never submitted).

in line 2607 of /sites/all/modules/webform/webform.module i tryed to check the $cid:

      $cid = webform_get_cid($node, $form_key, $parent);
      // add !is_null($cid) &&
      if(!is_null($cid) && is_array($value) && webform_component_feature($node->webform['components'][$cid]['type'], 'group')) {
        $values += _webform_client_form_submit_flatten($node, $value, $cid);
      }
      else {
        $values[$cid] = $value;
      }

but obviously doesnt work.

Looks like in my case the problem is caused by moving elements; Am I doing it in the wrong way, or is a bug?

Solved:

i was moving elements in the wrong way. Now im using $form['#pre_render'], and the problem is solved.

quicksketch’s picture

Issue summary: View changes
Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

I finally got around to working with @nathan6137's form. Upon importing, I received several messages of this sort:

    The webform component layout_box is not able to be displayed
    The webform component layout_box is not able to be displayed
    The webform component table_element is not able to be displayed
    The webform component table_element is not able to be displayed
    The webform component table_element is not able to be displayed
    The webform component table_element is not able to be displayed

The problem with undefined indexes is likely caused by these modules modifying the layout of the Webform. Other than the notices thrown because these component types were missing, I encountered no other notices like the ones described here.

So again, it doesn't look like Webform is responsible here. Although we could supress the errors by doing an isset() check, the errors *should* be thrown, because there is something wrong with the provided structure. The module causing the incorrect structure should remedy the problem.

darksnow’s picture

StatusFileSize
new938 bytes

I'm getting the same issue and in my case I think it's down to me messing with form elements in code. I assume this means they don't get a CID for some reason.

The flatten function just creates an array of form element values indexed by the CID

If there's no CID then there's nothing to put the value against so nothing should appear in that array. For my use case that's fine though I appreciate that this could be an issue for some.

The patch I've attached is simple defensive programming which checks that we have a $cid before using it. It's nothing more than an IF statement round the whole thing. I think it should be committed anyway since defensive programming is just good practice.

Cheers.

Martin.

danchadwick’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing as this looks like a damaged / modified webform. I'm not a fan of adding lots of defensive programming against damaged data structures that should never be damaged. It leads to unbounded code bloat.