Bug #81684

Flexform sections can't be created until content element is saved

Added by José Ricardo over 4 years ago. Updated 8 months ago.

Under Review
Should have
FormEngine aka TCEforms
Target version:
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:



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.


Components.xml (1.73 KB) Components.xml José Ricardo, 2017-06-22 20:43
flexform_quickgooglemap.xml (10.1 KB) flexform_quickgooglemap.xml Fabian König, 2018-09-10 16:35
xdebug_add_datalayer.png (78.6 KB) xdebug_add_datalayer.png Tomas Norre Mikkelsen, 2021-02-23 13:11
Add_plugin_xdebug.png (8.75 KB) Add_plugin_xdebug.png Tomas Norre Mikkelsen, 2021-02-24 14:41
add_datalayer_before_safe.png (4.93 KB) add_datalayer_before_safe.png Tomas Norre Mikkelsen, 2021-02-24 14:41

Updated by José Ricardo over 4 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 3 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 3 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 3 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 2 years ago

Did any of the watchers find a solution to this yet?


Updated by Christian Eßl about 2 years ago

  • Category set to FormEngine aka TCEforms

Updated by Georg Ringer over 1 year 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 8 months 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.


Updated by Tomas Norre Mikkelsen 8 months 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 8 months 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 8 months ago

Here is the change that removed the usages of




Updated by Tomas Norre Mikkelsen 8 months 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 8 months ago

I have created a V10 branch of the extension.

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 8 months ago

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 8 months ago

it works with the following flexform

                        <title>DataLayer Values:</title>
                                <title>DataLayer Value</title>
                                <el type="array">

it currently does not work with having settings.datalayersvars. so I guess it is again a missing escape thing


Updated by Tomas Norre Mikkelsen 8 months 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 8 months ago

I tested with 10.4


Updated by Tomas Norre Mikkelsen 8 months ago

I have made a small screencast with to show the problem


Updated by Tomas Norre Mikkelsen 8 months ago

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:

As we see, at least the returnUrl has some defVals defined, but as this commit:

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 8 months 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 8 months 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 8 months 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

Also available in: Atom PDF