You are here

function _webform_csv_headers_component in Webform 7.4

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

Return the header for this component to be displayed in a CSV file.

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.

Return value

array An array of data to be displayed in the first three rows of a CSV file, not including either prefixed or trailing commas.

Related topics

File

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

Code

function _webform_csv_headers_component($component, $export_options) {
  $header = array();
  $header[0] = array(
    '',
  );
  $header[1] = array(
    $export_options['header_keys'] ? $component['form_key'] : $component['name'],
  );
  $items = _webform_component_options($component['extra']['questions']);
  $count = 0;
  foreach ($items as $key => $item) {

    // Empty column per sub-field in main header.
    if ($count != 0) {
      $header[0][] = '';
      $header[1][] = '';
    }

    // The value for this option.
    $header[2][] = $item;
    $count++;
  }
  return $header;
}