Bug #89203
closed
FormEngine requireJsModules cannot load thirdparty modules
Added by Rene K about 5 years ago.
Updated almost 5 years ago.
Category:
FormEngine aka TCEforms
Description
The documentation says that it should be possible to load custom requiesJs modules from own extensions via namespace mapping like
TYPO3/CMS/FooBar/MyMagicModule => EXT:foo_bar/Resources/Public/JavaScript/MyMagicModule.js
however this does not work because the namespace seems to be ignored and the browser console logs error 404 trying to load
typo3/Foobar/MyMagicModule.js
Correction of path result:
typo3/TYPO3/CMS/Foobar/MyMagicModule.js
- Status changed from New to Needs Feedback
I can't confirm the issue, ist the extension loaded? Else this will not work.
The namespaces are registered automatically if the extension is installed.
TYPO3/CMS/FooBar will point to EXT:foo_bar/Resources/Public/JavaScript/
Is it possible to provide a demo extension to show the problem?
Yes, the extension is loaded. It happens by extending TYPO3\CMS\Backend\Form\Element\AbstractFormElement
by configuration:
'config' => [
'type' => 'user',
'renderType' => 'SomethingElement',
'parameters' => [
]
],
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1568875204] = [
'nodeName' => 'SomethingElement',
'priority' => 40,
'class' => SomethingElement::class
];
class SomethingElement extends AbstractFormElement {
public function render()
{
$result = $this->initializeResultArray();
...
$result['requireJsModules'][] = 'TYPO3/CMS/FooBar/SomethingElement'; // does not work: /typo3/TYPO3/CMS/FooBar/SomethingElement.js -> "script error"
$result['requireJsModules'][] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL')
. 'typo3conf/ext/foo_bar/Resources/Public/JavaScript/SomethingElement.js'; // works
return $result;
}
}
The extension is using a key like this: abc_something_xyz which is translated to AbcSomethingXyz.
Could multiple underscores cause the issue?
The extension is using a key like this: abc_something_xyz which is translated to AbcSomethingXyz.
Could multiple underscores cause the issue?
No, this should not be problem.
I use the same code as you posted in v9 and v10 without any problems, my modules loaded as expected.
If the extension is loaded, a requireJs config will be generated. You can check this, by opening the source code of the frame.
In the beginning of the document you will find something like this:
var require = {"paths": .... {"TYPO3\/CMS\/Core":"\/typo3\/sysext\/core\/Resources\/Public\/JavaScript" ....}
please check if you find the config for your extension, the config should contain a path mapping for your extension.
Well something strange is going on here - suddenly it does what it should with the correct path.
Thanks for this hint. I will check the config object if the bug occurs again.
- Status changed from Needs Feedback to Closed
No feedback since the last 90 days => closing this issue.
If you think that this is the wrong decision or experience the issue again and have more information about how to reproduce your problem, please reopen it or open a new issue with a reference to this one.
Thank you and best regards
Also available in: Atom
PDF