Bug #89203

FormEngine requireJsModules cannot load thirdparty modules

Added by Rene K about 1 month ago. Updated 10 days ago.

Status:
Needs Feedback
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2019-09-19
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

History

#1 Updated by Rene K about 1 month ago

Correction of path result:

typo3/TYPO3/CMS/Foobar/MyMagicModule.js

#2 Updated by Frank Naegler 29 days ago

  • 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?

#3 Updated by Rene K 29 days ago

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?

#4 Updated by Frank Naegler 10 days ago

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.

#5 Updated by Rene K 10 days ago

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.

Also available in: Atom PDF