The bug:

  • If the webform contains Review page then submitting/confirming of such Review page causes: Notice: Undefined index: submitted in webform_validation_validate() (line 159 of .../webform_validation/webform_validation.module).
  • When the Review page is confirmed (submitted) the $form_state['values']['submitted'] is not set as there are no submitted data for the values. In the Review page form there are only inputs with type="hidden" or type="submit".
  • Code causing the problem was added as a fix for the "Do not validates components hidden by conditional actions" bug, #2348403: Do not validates components hidden by conditional actions. The code is below:
webform_validation_prefix_keys($node->webform['components']);
// Remove hidden components.
foreach ($component_definitions as $key => $component) {
  if (_webform_client_form_rule_check($node, $component, 0, $form_state['values']['submitted']) !== WEBFORM_CONDITIONAL_INCLUDE) {
	unset($flat_values[$key]);
  }
}

The solution:

  • Check if the $form_state['values']['submitted'] isn't set. If so then skip the new functionality "Remove hidden components." because it has no meaning.
  • If $form_state['values']['submitted'] isn't set then the $values variable is NULL and thus the $flat_values variable is empty array:
$values = isset($form_state['values']['submitted']) ? $form_state['values']['submitted'] : NULL;
$flat_values = _webform_client_form_submit_flatten($node, $values);

Provided patch contains this code:

if (!empty($flat_values)) { // Newly added line of code.
  foreach ($component_definitions as $key => $component) {
    if (_webform_client_form_rule_check($node, $component, 0, $form_state['values']['submitted']) !== WEBFORM_CONDITIONAL_INCLUDE) {
      unset($flat_values[$key]);
    }
  }
} // Newly added line of code.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Liam Morland’s picture

Version: 7.x-1.8 » 7.x-1.x-dev
Priority: Normal » Major
Issue summary: View changes

Thanks for the report. Please try the development version. Your fix is there.

  • Liam Morland committed 77a103e on 7.x-1.x
    Issue #2421647: More robust solution to undefined index in...
Liam Morland’s picture

Priority: Major » Normal
Status: Needs review » Fixed

More robust solution committed. Thanks.

Status: Fixed » Closed (fixed)

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