function _webform_submit_select in Webform 6.3
Same name and namespace in other branches
- 5.2 components/select.inc \_webform_submit_select()
- 5 components/select.inc \_webform_submit_select()
- 6.2 components/select.inc \_webform_submit_select()
- 7.4 components/select.inc \_webform_submit_select()
- 7.3 components/select.inc \_webform_submit_select()
Implements _webform_submit_component().
Convert FAPI 0/1 values into something saveable.
File
- components/
select.inc, line 539 - Webform module multiple select component.
Code
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])) {
// 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;
}
}
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;
}