Bug #81684
closedFlexform sections can't be created until content element is saved
100%
Description
Hi,
I have a very simple flexform (attached) which adds a section to a tt_content record. If i try to add items on it before saving the content, it is not added and the on the browse console I can get the error:
#1476107295: PHP Warning: Invalid argument supplied for foreach() in .../typo3_src/typo3/sysext/backend/Classes/Form/Container/FlexFormElementContainer.php line 47 (More information) TYPO3\CMS\Core\Error\Exception thrown in file .../typo3_src/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 112.
Thought it was related to #80825, but the solution for it didn't solved this problem.
If the tt_content record is already saved, the items of section are added normally.
Other data not in sections works fine.
It works fine on TYPO3 7.
I've tested this on 8.7.1 and 8.7.2 and none works.
Files
Updated by José Ricardo over 7 years ago
- Related to Bug #80825: FlexForm Sections don't get saved before the parent record was stored to the DB added
Updated by Fabian König about 6 years ago
I have the exact same error in Typo3 Version 8.7.10. See my flexform.xml attached.
Is there a fix avaiable? Otherwise flexform sections cannot be used productive as the editor has to always save a newly created content element to avoid this error.
Updated by Fabian König about 6 years ago
- Related to deleted (Bug #80825: FlexForm Sections don't get saved before the parent record was stored to the DB)
Updated by Lorenz Ulrich almost 6 years ago
I have the same issue. Somehow it only seems to be an issue of you use type array
. I will see what I find out.
Updated by Lorenz Ulrich over 5 years ago
Did any of the watchers find a solution to this yet?
Updated by Christian Eßl about 5 years ago
- Category set to FormEngine aka TCEforms
Updated by Georg Ringer over 4 years ago
- Status changed from New to Accepted
in 10.4-dev it adds an empty section header and fails to persist.
Updated by Tomas Norre Mikkelsen almost 4 years ago
I'm experiencing this problem after updating from 7.6 as well.
If someone needs examples, this public extension of ours has the problem.
https://github.com/AOEpeople/TYPO3-Google-Tag-Manager
Updated by Tomas Norre Mikkelsen almost 4 years ago
I'm not quite there yet, but to me, it looks like
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
From "Configuration/TCA/Overrides/tt_content.php" isn't respected any more.
Updated by Tomas Norre Mikkelsen almost 4 years ago
If I fake it and add it manually to
$GLOBALS["TCA"]["tt_content"]["types"]["list"]["showitem"] = $GLOBALS["TCA"]["tt_content"]["types"]["list"]["showitem"] . ',pi_flexform';
it works again. But I don't like the solution. The bug is still there.
Updated by Tomas Norre Mikkelsen almost 4 years ago
Here is the change that removed the usages of
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']
Updated by Tomas Norre Mikkelsen over 3 years ago
Steps to reproduce the problem, I have choose TYPO3 8.7 for the steps as the extension I have the problem with is compatible with that.
The problem has been confirmed in newer TYPO3 version like 9.5 and 10.4 as well by me, but I don't have public extension to reference for that.
1. Start a TYPO3 Installaction (e.g. with DDEV) TYPO3 Version 8.7
2. Install https://github.com/AOEpeople/TYPO3-Google-Tag-Manager
3. Add following PageTS to a PageTS
# add GTM plugin to the content wizard mod.wizards.newContentElement.wizardItems.plugins.elements.googletagmanager_datalayer { iconIdentifier = tx-google-tag-manager title = Plugins : Google Tag Manager description = Google Tag Manager Data Layer tt_content_defValues { CType = list list_type = googletagmanager_datalayer } } mod.wizards.newContentElement.wizardItems.plugins.show := addToList( googletagmanager_datalayer )
4. On the same page, add a new elment of the "Google Tag Manager", It's important that you select the "google tag manager" directly, so that the element will not be saved first.
5. Go to the plugin tab, and click "Add Datalayer", and you will see that and "foobar" element is added.
A work around is to save the element before clicking the "Add Datalayer" and after that the element will look correct when added.
Updated by Tomas Norre Mikkelsen over 3 years ago
I have created a V10 branch of the extension.
https://github.com/AOEpeople/TYPO3-Google-Tag-Manager/tree/tnm/v10test
It Can be that the extension isn't compatible with 10 LTS, but changing the composer.json and ext_emconf.php is enough to reproduce the problem in 10.4 as well.
Updated by Tomas Norre Mikkelsen over 3 years ago
- File xdebug_add_datalayer.png xdebug_add_datalayer.png added
In the first debug loop, when added the "Google Tag Manager" elmenet before switching to the profile tab, the "columnsToRemove" doesn't contain "pi_flexform", but when adding datalayer then it's part of "columnsToRemove".
Updated by Georg Ringer over 3 years ago
it works with the following flexform
<settingsdatalayervars> <title>DataLayer Values:</title> <type>array</type> <section>1</section> <el> <datalayervar> <type>array</type> <title>DataLayer Value</title> <el type="array"> <label> <TCEforms> <label>Label:</label> <config> <type>input</type> <eval>trim</eval> </config> </TCEforms> </label> <value> <TCEforms> <label>Value:</label> <config> <type>input</type> <eval>trim</eval> </config> </TCEforms> </value> </el> </datalayervar> </el> </settingsdatalayervars>
it currently does not work with having settings.datalayersvars
. so I guess it is again a missing escape thing
Updated by Tomas Norre Mikkelsen over 3 years ago
Thanks for your input Georg. It doesn't change anything in my setup.
Still failing the same way as before.
Updated by Tomas Norre Mikkelsen over 3 years ago
I have made a small screencast with to show the problem
https://www.dropbox.com/s/a045mmnnm6k1m5h/flexform.mp4?dl=0
Updated by Tomas Norre Mikkelsen over 3 years ago
- File add_datalayer_before_safe.png add_datalayer_before_safe.png added
- File Add_plugin_xdebug.png Add_plugin_xdebug.png added
When adding the plugin at first, the default values are set.
But when the plugin is added, and pressing "add Datalayer" then the default values is empty, and therefore it's not added to the rendering.
URL from "add datalayer" button:
http://typo3test.ddev.site/typo3/index.php?route=/record/edit&token=26e48e0d68493dec0469b133cfa56ed790e1326a&edit[tt_content]1=new&defVals[tt_content][colPos]=0&defVals[tt_content][sys_language_uid]=0&returnUrl=/typo3/index.php?route=%2Fmodule%2Fweb%2Flayout&token=7c490bc7d8a11f0e01428443b07ec05d38967c88&id=1&&defVals[tt_content][CType]=list&defVals[tt_content][list_type]=googletagmanager_datalayer
As we see, at least the returnUrl has some defVals defined, but as this commit:
https://github.com/TYPO3/TYPO3.CMS/commit/d29d4b5f7be4ec5d024b3d67e7e4abe97bbe4c46
It looks like it's fetched from somewhere else and not over the _GP anymore.
I'm not sure what the fix is, but I'm quite sure that this is the problem.
Please correct me if I'm wrong.
This is btw. from a TYPO3 10.4.13
Updated by Tomas Norre Mikkelsen over 3 years ago
I think I have located the Problem, but not the solution.
The $formDataCompilerInput['databaseRow'] is besides 'uid' empty, therefor there will never be found any default values for the list_type.
FormFlexAjaxController.php Line: 74
$formDataCompilerInput = [ 'tableName' => $tableName, 'vanillaUid' => (int)$vanillaUid, 'command' => $command, 'recordTypeValue' => $recordTypeValue, 'processedTca' => $processedTca, 'flexSectionContainerPreparation' => $flexSectionContainerPreparation, ]; // A new container on a new record needs the 'NEW123' uid here, see comment // in DatabaseUniqueUidNewRow for more information on that. // @todo: Resolve, maybe with a redefinition of vanillaUid to transport the information more clean through this var? // @see issue #80100 for a series of changes in this area if ($command === 'new') { $formDataCompilerInput['databaseRow']['uid'] = $databaseRowUid; } $formData = $formDataCompiler->compile($formDataCompilerInput);
Therefore the flexform isn't added to the showItems
Updated by Tomas Norre Mikkelsen over 3 years ago
Adding this to the FlexFormAjaxController, solves the problem for me. I'll sleep on this over the weekend, and see if I find any problems or better approaches before I push it for review.
if ($command === 'new') { $formDataCompilerInput['databaseRow']['uid'] = $databaseRowUid; + $dataStructureKey = $queryParameters['dataStructureIdentifier']['dataStructureKey']; + $subtypeValue = substr($dataStructureKey, 0, strpos($dataStructureKey, ',')); + $formDataCompilerInput['databaseRow'][$processedTca['types'][$recordTypeValue]['subtype_value_field']] = $subtypeValue; }
Updated by Gerrit Code Review over 3 years ago
- Status changed from Accepted 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/c/Packages/TYPO3.CMS/+/68152
Updated by Gerrit Code Review about 3 years 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/c/Packages/TYPO3.CMS/+/68152
Updated by Gerrit Code Review about 3 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68152
Updated by Gerrit Code Review about 3 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68152
Updated by Gerrit Code Review about 3 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68152
Updated by Gerrit Code Review about 3 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/68152
Updated by Gerrit Code Review about 3 years ago
Patch set 1 for branch 10.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/+/72147
Updated by Gerrit Code Review about 3 years ago
Patch set 2 for branch 10.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/+/72147
Updated by Tomas Norre Mikkelsen about 3 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 1d1712bf33858861fdf02bc27f56dec00a489799.