Bug #85710

tx_form: Multiple Extensions with YAML additionalViewModel overwrite configuration array

Added by David Bascom 3 months ago. Updated 17 days ago.

Status:
Under Review
Priority:
Must have
Assignee:
Category:
Form Framework
Target version:
-
Start date:
2018-08-01
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

We have an Typo3 8.7.17 installation with two custom extensions.

Both extensions extend the tx_form with a custom formelement and add a JS-module using the additionalViewModelModules in YAML.
Only the additionalViewModelModules array of the last extension is respected and loads the JS-modules from ...Resources/Public/JavaScript/Backend/FormEditor/...
This results in an empty backend-preview for the formelement of the first extension.

The FormEditorSetup.yaml of the first extension:

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formEditor:
            dynamicRequireJsModules:
              additionalViewModelModules:
                - 'TYPO3/CMS/Nnscouts/Backend/FormEditor/NnscoutsViewmodel'

The FormEditorSetup.yaml of the second extension:

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formEditor:
            dynamicRequireJsModules:
              additionalViewModelModules:
                - 'TYPO3/CMS/Dsgvo/Backend/FormEditor/DsgvoViewModel'

Reason seems to be that the merge of the arrays from additionalViewModelModules fails: Actually it is not merged, but the array of ext2 replaces the array of ext1 – or in other words: by the extension that was loaded last.

We made sure, that both YAML-configurations are loaded correctly and the JS-files are at the right place.
Removing the dynamicRequireJsModules-section from the second extension and adding a additional item to the array of the first extension – and vice versa – works:

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formEditor:
            dynamicRequireJsModules:
              additionalViewModelModules:
                - 'TYPO3/CMS/Dsgvo/Backend/FormEditor/DsgvoViewModel'
                - 'TYPO3/CMS/Nnscouts/Backend/FormEditor/NnscoutsViewmodel'

History

#1 Updated by Steffen Gebert 3 months ago

Hi,

sorry, this is the bug tracker of the bug tracker..

#2 Updated by Steffen Gebert 3 months ago

  • Project changed from forge.typo3.org to TYPO3 Core
  • Category deleted (Development)
  • TYPO3 Version set to 8

#3 Updated by Julian Wundrak 2 months ago

I can reproduce this behavior in TYPO3 9.3.3.

My temporary solution is using keys, like:

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formEditor:
            dynamicRequireJsModules:
              additionalViewModelModules:
                0: 'TYPO3/CMS/Dsgvo/Backend/FormEditor/DsgvoViewModel'
                1: 'TYPO3/CMS/Nnscouts/Backend/FormEditor/NnscoutsViewmodel'

Notice, that the keys are successive. Else additionalViewModelModules is an object instead of an array, and this crashes here: Resources/Public/JavaScript/Backend/FormEditor.js:FromEditor::_viewSetup()

I believe, it is not so easy to not allow 'merging' this configuration, so maybe it would be easier to allow objects in additionalViewModelModules.

To use


additionalViewModelModules:
  10: '...' 
  20: '...'

i using this patch for the _viewSetup()-Method

if (!getUtility().isUndefinedOrNull(additionalViewModelModules)) {
    if ('object' === $.type(additionalViewModelModules)) {
        additionalViewModelModules = Object.values(additionalViewModelModules);
    }

    assert('array' === $.type(additionalViewModelModules), 'Invalid parameter "additionalViewModelModules"', 1475379752);
}

#4 Updated by Riccardo De Contardi 2 months ago

  • Category set to Form Framework

#5 Updated by Gerrit Code Review about 2 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58106

#6 Updated by Gerrit Code Review 17 days ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58106

Also available in: Atom PDF