- Issue created by @dougiep
- 🇦🇺Australia dougiep
I have a patch made already that I have applied, but what needs to be investigated is whether this would break some other functionality.
--- a/src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php +++ b/src/Plugin/Field/FieldFormatter/ParagraphsTableFormatter.php @@ -458,6 +458,11 @@ class ParagraphsTableFormatter extends EntityReferenceFormatterBase { foreach ($handler["target_bundles"] as $targetBundle) { + // Skip rendering table if no entities exist and AJAX is not enabled + if (empty($entities) && empty($setting['ajax'])) { + continue; + } + $table = $table_header = $fields = []; $table_rows = $notEmptyColumn = []; if ($setting['number_column']) { @@ -658,6 +663,12 @@ class ParagraphsTableFormatter extends EntityReferenceFormatterBase { } $addButton = NULL; + + // Don't show add button if no entities exist and no table was rendered + if (empty($entities) && empty($setting['ajax']) && empty($output)) { + return $output; + } + $userRoles = $this->currentUser->getRoles(); $cardinality = $field_definition->getFieldStorageDefinition()->get('cardinality'); if ($entityId &&