You are here

public function YamlFormCompositeBase::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/YamlFormCompositeBase.php, line 551

Class

YamlFormCompositeBase
Provides a base for composite elements.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function buildExportHeader(array $element, array $options) {
  $composite_elements = $this
    ->getInitializedCompositeElement($element);
  $header = [];
  foreach (RenderElement::children($composite_elements) as $composite_key) {
    $composite_element = $composite_elements[$composite_key];
    if (isset($composite_element['#access']) && $composite_element['#access'] === FALSE) {
      continue;
    }
    if ($options['header_format'] == 'label' && !empty($composite_element['#title'])) {
      $header[] = $composite_element['#title'];
    }
    else {
      $header[] = $composite_key;
    }
  }
  return $this
    ->prefixExportHeader($header, $element, $options);
}