Project

General

Profile

Actions

Feature #75652

closed

User-Elements cannot add RequireJS-Modules

Added by Robert Vock about 8 years ago. Updated over 5 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2016-04-15
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

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
);
Actions

Also available in: Atom PDF