function _webform_submission_display_select in Webform 5
Same name and namespace in other branches
- 5.2 components/select.inc \_webform_submission_display_select()
- 6.2 components/select.inc \_webform_submission_display_select()
Display the result of a textfield submission. The output of this function will be displayed under the "results" tab then "submissions".
Parameters
$data: An array of information containing the submission result, directly correlating to the webform_submitted_data database schema.
$component: An array of information describing the component, directly correlating to the webform_component database schema.
Return value
Textual output formatted for human reading.
File
- components/
select.inc, line 173
Code
function _webform_submission_display_select($data, $component, $enabled = false) {
$form_item = _webform_render_select($component);
if ($component['extra']['multiple'] == 'Y') {
// Set the value as an array.
foreach ((array) $data['value'] as $key => $value) {
if (array_key_exists(_webform_safe_name($value), $form_item['#options'])) {
$form_item['#default_value'][] = _webform_safe_name($value);
}
else {
$form_item['#default_value'][] = $value;
}
}
}
else {
// Set the value as a single string.
foreach ((array) $data['value'] as $value) {
if ($value !== '0') {
if (array_key_exists(_webform_safe_name($value), $form_item['#options'])) {
$form_item['#default_value'] = _webform_safe_name($value);
}
else {
$form_item['#default_value'] = $value;
}
break;
}
}
}
$form_item['#disabled'] = !$enabled;
return $form_item;
}