protected function EntityReferenceBrowserTableWidget::displayCurrentSelection in Entity Browser - Table Layout 8
Builds the render array for displaying the current results as a table.
Parameters
string $details_id: The ID for the details element.
string[] $field_parents: Field parents.
\Drupal\Core\Entity\ContentEntityInterface[] $entities: Array of referenced entities.
Return value
array The render array for the current selection.
File
- src/
Plugin/ Field/ FieldWidget/ EntityReferenceBrowserTableWidget.php, line 152
Class
- EntityReferenceBrowserTableWidget
- Plugin implementation of the 'entity_reference_browser_table_widget' widget.
Namespace
Drupal\entity_browser_table\Plugin\Field\FieldWidgetCode
protected function displayCurrentSelection($details_id, array $field_parents, array $entities) {
try {
$table = [
'#type' => 'table',
'#header' => $this
->buildTableHeaders(),
'#attributes' => [
'class' => [
'table--widget-' . $this
->getPluginId(),
],
],
'#empty' => $this
->t('Use the buttons above to add content to this area.'),
];
return array_merge($table, $this
->buildTableRows($entities, $details_id, $field_parents));
} catch (PluginException $exception) {
\Drupal::logger('Entity Browser - Table Display')
->error(t('Could not get the field widget display: @message', [
'@message' => $exception
->getMessage(),
]));
return $table = [
'#type' => 'table',
'#header' => [
'',
],
'#rows' => [
[
$this
->t('The field widget could not be found. See the logs for details'),
],
],
];
}
}