Bug #85710

tx_form: Multiple Extensions with YAML additionalViewModel overwrite configuration array

Added by David Bascom 4 months ago. Updated about 1 month ago.

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

100%

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'

Associated revisions

Revision 6939d0da (diff)
Added by Ralf Zimmermann about 1 month ago

[BUGFIX] Registration of multiple additional view models

The form setup properties within "additionalViewModelModules" must be
written as numerical associative arrays to make it possible that
multiple extensions can extend the form editor with javascript modules.

Resolves: #85710
Releases: master, 8.7
Change-Id: Iaddf1bfd6f4df8d0c01e0c18be9cef458d8d2caf
Reviewed-on: https://review.typo3.org/58106
Tested-by: TYPO3com <>
Reviewed-by: Daniel Goerz <>
Reviewed-by: Susanne Moog <>
Tested-by: Susanne Moog <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

Revision ed43dbe7 (diff)
Added by Ralf Zimmermann about 1 month ago

[BUGFIX] Registration of multiple additional view models

The form setup properties within "additionalViewModelModules" must be
written as numerical associative arrays to make it possible that
multiple extensions can extend the form editor with javascript modules.

Resolves: #85710
Releases: master, 8.7
Change-Id: Iaddf1bfd6f4df8d0c01e0c18be9cef458d8d2caf
Reviewed-on: https://review.typo3.org/58768
Tested-by: TYPO3com <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

History

#1 Updated by Steffen Gebert 4 months ago

Hi,

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

#2 Updated by Steffen Gebert 4 months ago

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

#3 Updated by Julian Wundrak 4 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 4 months ago

  • Category set to Form Framework

#5 Updated by Gerrit Code Review 3 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 2 months 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

#7 Updated by Gerrit Code Review about 1 month ago

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

#8 Updated by Ralf Zimmermann about 1 month ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF