protected function FieldGroupTable::getRowItem in Field Group Table 8
Return item definition array.
Parameters
array $element: Rendering array.
string $field_name: Item field machine name.
Return value
array Item definition array on success or empty array otherwise.
1 call to FieldGroupTable::getRowItem()
- 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 391
Class
- FieldGroupTable
- Plugin implementation of the 'field_group_table' formatter.
Namespace
Drupal\field_group_table\Plugin\field_group\FieldGroupFormatterCode
protected function getRowItem(array $element, $field_name) {
$item = isset($element[$field_name]) ? $element[$field_name] : [];
$is_empty = !is_array($item) || !array_intersect($this->renderApiProperties, array_keys($item));
if ($is_empty && $this
->getSetting('always_show_field_value') && isset($element['#entity_type'], $element['#bundle'])) {
$field_definitions = $this->entityFieldManager
->getFieldDefinitions($element['#entity_type'], $element['#bundle']);
$field_definition = isset($field_definitions[$field_name]) ? $field_definitions[$field_name] : NULL;
if ($field_definition instanceof FieldConfigInterface) {
$is_empty = FALSE;
$item = [
'#title' => $field_definition
->label(),
'#label_display' => 'above',
'#markup' => Xss::filter($this
->getSetting('empty_field_placeholder')),
];
}
}
return $is_empty ? [] : $item;
}