function _webform_csv_data_select in Webform 5
Same name and namespace in other branches
- 5.2 components/select.inc \_webform_csv_data_select()
- 6.3 components/select.inc \_webform_csv_data_select()
- 6.2 components/select.inc \_webform_csv_data_select()
- 7.4 components/select.inc \_webform_csv_data_select()
- 7.3 components/select.inc \_webform_csv_data_select()
Return 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.
Return value
Textual output formatted for CSV, not including either prefixed or trailing commas.
File
- components/
select.inc, line 427
Code
function _webform_csv_data_select($data, $component) {
$value = _webform_filtervalues($component['value'], FALSE);
$rows = explode("\n", _webform_filtervalues($component['extra']['items'], FALSE));
$options = array();
foreach ($rows as $row) {
$row = trim($row);
if (preg_match('/^([^"|]+)\\|(.*)$/', $row, $matches)) {
$options[$matches[1]] = $matches[2];
}
else {
$options[_webform_safe_name($row)] = $row;
}
}
if ($component['extra']['multiple']) {
foreach ($options as $key => $item) {
if (in_array($item, (array) $data['value']) === true || in_array($key, (array) $data['value']) === true) {
$output .= '\\,Yes';
}
else {
$output .= '\\,No';
}
}
// Remove the preceding extra comma.
$output = substr($output, 2);
}
else {
$output = $data['value'][0];
}
return $output;
}