You are here

public function OptionsBase::buildExportHeader in YAML Form 8

Build an element's export header.

Parameters

array $element: An element.

array $options: An associative array of export options.

Return value

array An array containing the element's export headers.

Overrides YamlFormElementBase::buildExportHeader

See also

\Drupal\yamlform\YamlFormSubmissionExporterInterface::getDefaultExportOptions

File

src/Plugin/YamlFormElement/OptionsBase.php, line 348

Class

OptionsBase
Provides a base 'options' element.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function buildExportHeader(array $element, array $options) {
  if ($options['options_format'] == 'separate' && isset($element['#options'])) {
    $header = [];
    foreach ($element['#options'] as $option_value => $option_text) {

      // Note: If $option_text is an array (typically a tableselect row)
      // always use $option_value.
      $title = $options['options_item_format'] == 'key' || is_array($option_text) ? $option_value : $option_text;
      $header[] = $title;
    }
    return $this
      ->prefixExportHeader($header, $element, $options);
  }
  else {
    return parent::buildExportHeader($element, $options);
  }
}