Project

General

Profile

Actions

Bug #103174

closed

CustomFileControlsEvent does not support javaScriptModules

Added by Daniel Siepmann 9 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend JavaScript
Target version:
-
Start date:
2024-02-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.

Actions

Also available in: Atom PDF