Feature #75652
closedUser-Elements cannot add RequireJS-Modules
0%
Description
Currently TCA UserElements cannot add JavaScript to the resultArray of TYPO3\CMS\Backend\Form\AbstractNode. They can only manipulate the HTML:
https://github.com/TYPO3/TYPO3.CMS/blob/b63420e/typo3/sysext/backend/Classes/Form/Element/UserElement.php#L39
Of course it is possible to add the RequireJS-Modules directly:
GeneralUtility::makeInstance(PageRenderer::class)->loadRequireJsModule('TYPO3/CMS/EXTENSION/JS_MODULE');
But this does not work in inline-elements. The FormInlineAjaxController only checks the data in the result-array and adds it to the Ajax-Response:
https://github.com/TYPO3/TYPO3.CMS/blob/b63420e/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php#L658
An easy fix would be to add the resultArray as reference-parameter to the UserFunc:
$resultArray = $this->initializeResultArray(); $parameterArray['resultArray'] =& $resultArray; $resultArray['html'] = GeneralUtility::callUserFunction( $parameterArray['fieldConf']['config']['userFunc'], $parameterArray, $this );