This error occurs only when webform uses "select_or_other" feature.
Steps to reproduce:
- Create multi-page webform (at least 3 pages).
- Use mixture of select components on each webform page, some with select_or_other some without it.
- Now fill form's page 1 and page 2.
- On page 3 click "< Previous Page".
- The error occurs.
Now, although the error message relates to select.inc from webform module, the issue occurs only when select_or_other is used. This is the function from select.inc
function _webform_submit_select($component, $value) {
// Build a list of all valid keys expected to be submitted.
$options = _webform_select_options($component, TRUE);
$return = NULL;
if (is_array($value)) {
$return = array();
foreach ($value as $key => $option_value) {
// Handle options that are specified options.
if ($option_value !== '' && isset($options[$option_value])) { // <==== This is the line where error is thrown
// Checkboxes submit a value of FALSE when unchecked. A checkbox with
// a value of '0' is valid, so we can't use empty() here.
if ($option_value === FALSE && !$component['extra']['aslist'] && $component['extra']['multiple']) {
unset($value[$option_value]);
}
else {
$return[] = $option_value;
}
}
// Handle options that are added through the "other" field. Specifically
// exclude the "select_or_other" value, which is added by the select list.
elseif ($component['extra']['other_option'] && module_exists('select_or_other') && $option_value != 'select_or_other') {
$return[] = $option_value;
}
}
}
elseif (is_string($value)) {
$return = $value;
}
return $return;
}
I tried to do some debugging and it seems that select_or_other module changes one of $value array elements from string to array of strings. On line 510 webform expects that $option_value to be a string but it seems that select_or_other turns that string into array of strings.
I tried to fix that but I'm not familiar with webform API and got totally lost.
Aside from error on line 510 of select.inc, when you click "< Previous Page" the values from previous selection are not checked by default, but instead "Other" field is active and all values, comma separated, are put there.
Comments
Comment #1
danielb commentedhttp://drupal.org/node/966028#comment-5214126