Issue Bug Closed

#103174CustomFileControlsEvent does not support javaScriptModules

Daniel Siepmann 02/22/24, 07:20 updated 07/09/24, 15:33

Description

The event provides access to the `$resultArray` and allows to set a new version of that variable.
But the triggering code does not use the modified version.

That array holds a list of javaScriptModules to load. This info is not respected.

This worked prior the event when one used a UserFunction in order to add custom controls, as the resultArray was provided and could be handled as reference.

It seems I could fix this via:

diff --git a/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php b/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php
index c231c8d076..250e1b7e68 100644
--- a/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/FilesControlContainer.php
@@ -271,14 +271,15 @@ class FilesControlContainer extends AbstractContainer
             }
         }

-        $controls = $this->eventDispatcher->dispatch(
+        $event = GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch(
             new CustomFileControlsEvent($resultArray, $table, $field, $row, $config, $formFieldIdentifier, $formFieldName)
-        )->getControls();
+        );
+        $resultArray = $event->getResultArray();

-        if ($controls !== []) {
+        if ($event->getControls() !== []) {
             $view->assign('customControls', [
                 'id' => $formFieldIdentifier . '_customControls',
-                'controls' => implode("\n", $controls),
+                'controls' => implode("\n", $event->getControls()),
             ]);
         }

But then I end up with

Uncaught (in promise) Error: Unable to resolve specifier '@e2/e2-core/FilePathBasedBrowser/SearchForm.js' imported from http://localhost:8080/typo3/record/edit?token=a91f1f57ee42b3

I expect https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/12.0/Breaking-98479-RemovedFileReferenceRelatedFunctionality.html to be the change that broke the feature.

Reviews 2