protected function FieldGroupTable::buildRowView in Field Group Table 8
Build table row for a "view" context.
Parameters
array $element: Rendering array of an element.
Return value
array Table row for a "view" context.
1 call to FieldGroupTable::buildRowView()
- FieldGroupTable::buildRow in src/
Plugin/ field_group/ FieldGroupFormatter/ FieldGroupTable.php - Build table row for requested element.
File
- src/
Plugin/ field_group/ FieldGroupFormatter/ FieldGroupTable.php, line 422
Class
- FieldGroupTable
- Plugin implementation of the 'field_group_table' formatter.
Namespace
Drupal\field_group_table\Plugin\field_group\FieldGroupFormatterCode
protected function buildRowView(array $element) {
$label_display = isset($element['#label_display']) ? $element['#label_display'] : '';
$title_data = $this
->getElementTitleData($element);
$build = [];
// Display the label in the first column,
// if 'always show field label' is set.
if ($this
->getSetting('always_show_field_label')) {
$build['data'] = [
[
'data' => [
'#markup' => $title_data['title'],
],
'header' => TRUE,
],
[
'data' => $element,
],
];
}
elseif ($title_data['title'] && $label_display === 'above') {
$this
->hideElementTitle($element);
$build['data'] = [
[
'data' => [
'#markup' => $title_data['title'],
],
'header' => TRUE,
],
[
'data' => $element,
],
];
}
elseif ($this
->getSetting('empty_label_behavior') == self::EMPTY_LABEL_KEEP) {
$build['data'] = [
[
'data' => [
'#markup' => '',
],
'header' => TRUE,
],
[
'data' => $element,
],
];
}
else {
$build['data'] = [
[
'data' => [
$element,
],
'colspan' => 2,
],
];
}
if (isset($element['#field_name'])) {
$build['class'][] = Html::cleanCssIdentifier($element['#field_name']);
}
if (isset($element['#field_type'])) {
$build['class'][] = 'type-' . Html::cleanCssIdentifier($element['#field_type']);
}
return $build;
}