function _webform_action_set_select in Webform 7.4
Implements _webform_action_set_component().
File
- components/
select.inc, line 761 - Webform module multiple select component.
Code
function _webform_action_set_select($component, &$element, &$form_state, $value) {
// Set the value as an array for multiple select or single value otherwise.
if ($element['#type'] == 'checkboxes') {
$checkbox_values = $element['#options'];
array_walk($checkbox_values, function (&$option_value, $key) use ($value) {
$option_value = (int) (strval($key) === $value);
});
}
else {
$value = $component['extra']['multiple'] ? array(
$value,
) : $value;
}
$element['#value'] = $value;
form_set_value($element, $value, $form_state);
}