Bug #97042
closedFlexforms with mutliple sheets with same section names are not working anymore
100%
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
Updated by Riccardo De Contardi 5 months ago
- Related to Bug #99947: double modal dialog locks backend added
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
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
Updated by Garvin Hicking 5 months ago
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
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
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
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.
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
Updated by Garvin Hicking 5 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset bb573a3b47ac6c712459fbc6934970d5e3501c42.
Updated by Georg Ringer 4 months ago
- Related to Bug #100937: Flexform sections in TCA inline fields are broken added