You are here

public function YamlFormCompositeBase::formatTableColumn in YAML Form 8

Format an element's table column value.

Parameters

array $element: An element.

array|mixed $value: A value.

array $options: An array of options returned from ::getTableColumns().

Return value

array|string The element's value formatted as an HTML string or a render array.

Overrides YamlFormElementBase::formatTableColumn

File

src/Plugin/YamlFormElement/YamlFormCompositeBase.php, line 170

Class

YamlFormCompositeBase
Provides a base for composite elements.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

public function formatTableColumn(array $element, $value, array $options = []) {
  if (isset($options['composite_key']) && isset($options['composite_element'])) {
    $composite_key = $options['composite_key'];
    $composite_element = $options['composite_element'];
    $composite_value = $value[$composite_key];
    $composite_options = [];
    return $this->elementManager
      ->invokeMethod('formatHtml', $composite_element, $composite_value, $composite_options);
  }
  else {
    return $this
      ->formatHtml($element, $value);
  }
}