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.
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.
Comment | File | Size | Author |
---|---|---|---|
undefined-index-submitted-in-webform_validation_validate-function.patch | 884 bytes | dabbor | |
Comments
Comment #2
Liam MorlandThanks for the report. Please try the development version. Your fix is there.
Comment #4
Liam MorlandMore robust solution committed. Thanks.