Project

General

Profile

Actions

Bug #97042

closed

Flexforms with mutliple sheets with same section names are not working anymore

Added by Jessica Jagodzinski over 2 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2022-02-25
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If you have a flexform with several sheets with same section names, creating new elements does not work. This behavior was possible in TYPO3 9.

Example:
  • use FlexformExampleNotWorking.xml for an element (CE or plugin)
  • create an element
  • add a new "Example Section Element" in Tab 1
    • 2 elements will be created
  • try to add a new "Example Section Element" in Tab 2
    • nothing will happen

If you try FlexformExampleWorking.xml it will work, because the sections have different names.


Files

FlexformExampleNotWorking.xml (1.38 KB) FlexformExampleNotWorking.xml Jessica Jagodzinski, 2022-02-25 12:23
FlexformExampleWorking.xml (1.41 KB) FlexformExampleWorking.xml Jessica Jagodzinski, 2022-02-25 12:23
chrome-capture-2024-7-2.gif (2.66 MB) chrome-capture-2024-7-2.gif Video of the wrong behaviour Garvin Hicking, 2024-07-02 12:52

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #99947: double modal dialog locks backendClosed2023-02-14

Actions
Related to TYPO3 Core - Bug #100937: Flexform sections in TCA inline fields are brokenClosed2023-05-31

Actions
Actions #1

Updated by Riccardo De Contardi 5 months ago

  • Related to Bug #99947: double modal dialog locks backend added
Actions #2

Updated by Gerrit Code Review 5 months ago

  • Status changed from New to Under Review

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

Actions #3

Updated by Garvin Hicking 5 months ago ยท Edited

This is still reproducible in v13 main. I created a patch https://review.typo3.org/c/Packages/TYPO3.CMS/+/85083 for this.

Analysis

I could boil it down to this file Build/Sources/TypeScript/backend/form-engine/container/flex-form-section-container.ts :

  private registerCreateNewContainer(): void {
    new RegularEvent('click', (e: Event, target: HTMLElement): void => {
      e.preventDefault();
      this.createNewContainer(target.dataset);
    }).delegateTo(this.container, Selectors.addContainerSelector);
  }

When clicking the button, this event is fired multiple times at once, instead only for the one button you clicked. So as many buttons as there are in your flexform element, as many times the event is fired. Sadly I don't know enough JavaScript on how to limit the event for the actual button.

Steps to reproduce

  • Apply patch https://review.typo3.org/c/Packages/TYPO3.CMS/+/85083
  • Clear cache, run DB analyzer compare (new field created)
  • Check out the EXT:styleguide element "Form engine - flex" as a new record
  • Go to the tab "complex"
  • Inside tab "backend.flexform.servicebox.tab1" click on the bottom link "backend.flexform.servicebox.li..."
  • Now two items will be added to the "links" section, and a "console.log" JS statement will appear twice
  • Save the record
  • Edit it again
  • Click on a trashcan of that tab to delete one of the items. Two modals will appear, also the JS statement appears twice.

See attached video (GIF).

Solution

It should all fall into place if the event fired is only done on the one specific button, and not all instances with a matching selector

Actions #5

Updated by Gerrit Code Review 5 months ago

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

Actions #6

Updated by Gerrit Code Review 5 months ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85083

Actions #7

Updated by Gerrit Code Review 5 months ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85083

Actions #8

Updated by Garvin Hicking 5 months ago

The attached patch should resolve that, votes/comments in that patch are welcome if you can try it out. The actual reason for this was not JavaScript at all, but that the same flexform container name was just referenced in HTML via:

<div id="flexform-section-container-fieldName-flexformField-4711">

but now the flexform sheet name is also attached, making the field unique then:

<div id="flexform-section-container-sheetName-fieldName-flexformField-4711">

This should fix all reported issues: Duplicate items only in the first section and not the "real" one, and inability to remove an item without getting two modals overlaying each other.

Actions #9

Updated by Gerrit Code Review 5 months ago

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

Actions #10

Updated by Garvin Hicking 5 months ago

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

Updated by Benni Mack 4 months ago

  • Status changed from Resolved to Closed
Actions #12

Updated by Georg Ringer 4 months ago

  • Related to Bug #100937: Flexform sections in TCA inline fields are broken added
Actions

Also available in: Atom PDF