From b32e985b5cbc55846bee1b40268c222436baa795 Mon Sep 17 00:00:00 2001
From: Oliver Bartsch <bo@cedev.de>
Date: Wed, 27 Dec 2023 10:09:37 +0100
Subject: [PATCH] [BUGFIX] Do not render empty link explanation callout

In case a link does not set any additional
attributes, no empty callout is rendered.

Resolves: #102721
Releases: main, 12.4
Change-Id: I7ec4d7b64450112731363d721f4d49322448b41c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82294
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
---
 typo3/sysext/backend/Classes/Form/Element/LinkElement.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/backend/Classes/Form/Element/LinkElement.php b/typo3/sysext/backend/Classes/Form/Element/LinkElement.php
index 52ebafd8e018..8986b75bc647 100644
--- a/typo3/sysext/backend/Classes/Form/Element/LinkElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/LinkElement.php
@@ -427,7 +427,9 @@ class LinkElement extends AbstractFormElement
                 ];
         }
 
-        $data['additionalAttributes'] = '<div class="form-text">' . implode(' - ', $additionalAttributes) . '</div>';
+        $data['additionalAttributes'] = $additionalAttributes !== []
+            ? '<div class="form-text">' . implode(' - ', $additionalAttributes) . '</div>'
+            : ''; // Ensure "additionalAttributes" is always set (bw compatibility for the event)
 
         return GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch(
             new ModifyLinkExplanationEvent($data, $linkData, $linkParts, $this->data)
-- 
GitLab