You are here

function _webform_csv_data_component in Webform 7.3

Same name and namespace in other branches
  1. 6.3 webform.api.php \_webform_csv_data_component()
  2. 7.4 webform.api.php \_webform_csv_data_component()

Format the submitted data of a component for CSV downloading.

The output of this function will be displayed under the "Results" tab then "Download".

Parameters

$component: A Webform component array.

$export_options: An array of options that may configure export of this field.

$value: An array of information containing the submission result, directly correlating to the webform_submitted_data database schema.

Return value

An array of items to be added to the CSV file. Each value within the array will be another column within the file. This function is called once for every row of data.

Related topics

File

./webform.api.php, line 998
Sample hooks demonstrating usage in Webform.

Code

function _webform_csv_data_component($component, $export_options, $value) {
  $questions = array_keys(_webform_select_options($component['extra']['questions']));
  $return = array();
  foreach ($questions as $key => $question) {
    $return[] = isset($value[$key]) ? $value[$key] : '';
  }
  return $return;
}