From 0538ca97dc7927856e475a6dc2d8b64a443df161 Mon Sep 17 00:00:00 2001
From: Benjamin Serfhos <serfhos@gmail.com>
Date: Thu, 11 May 2017 14:30:15 +0200
Subject: [PATCH] [BUGFIX] Flexform Form ID should not contain brackets

Using brackets in flexform elements caused the javascript to be disabled
for the element.
While using a custom form id that can be used as HTML id="" this is
bypassed and fixes all javascript interaction.

Releases: master, 8.7
Resolves: #80908
Change-Id: I91f39b2fed61076b7139603fedc7b268546d64cd
Reviewed-on: https://review.typo3.org/52771
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
---
 .../Classes/Form/Container/FlexFormElementContainer.php        | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/Container/FlexFormElementContainer.php b/typo3/sysext/backend/Classes/Form/Container/FlexFormElementContainer.php
index f085e8f31ec8..c73729a6518b 100644
--- a/typo3/sysext/backend/Classes/Form/Container/FlexFormElementContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/FlexFormElementContainer.php
@@ -111,8 +111,7 @@ class FlexFormElementContainer extends AbstractContainer
                         $fakeParameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = str_replace($originalFieldName, $fakeParameterArray['itemFormElName'], $fakeParameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged']);
                     }
                 }
-                // @todo: is that a bug? name and id should usually be of different form
-                $fakeParameterArray['itemFormElID'] = $fakeParameterArray['itemFormElName'];
+                $fakeParameterArray['itemFormElID'] = $parameterArray['itemFormElID'] . '_' . preg_replace('/[^a-zA-Z0-9_-]/', '_', $flexFormFieldName);
                 if (isset($flexFormRowData[$flexFormFieldName]['vDEF'])) {
                     $fakeParameterArray['itemFormElValue'] = $flexFormRowData[$flexFormFieldName]['vDEF'];
                 } else {
-- 
GitLab