FlexForms

FlexForms can be used to store data within an XML structure inside a single DB column.

Extbase plugin settings as FlexForm

FlexForms are commonly used to configure Extbase plugins:

packages/my_extension/Configuration/TCA/Overrides/tt_content.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

$ctypeKey = ExtensionUtility::registerPlugin(
    'MyExtension',
    'MyPlugin',
    'My Plugin Title',
    'my-extension-icon',
    'plugins',
    'Plugin description',
    'FILE:EXT:my_extension/Configuration/FlexForm.xml',
);

ExtensionManagementUtility::addToAllTCAtypes(
    'tt_content',
    '--div--;Configuration,pi_flexform,',
    $ctypeKey,
    'after:subheader',
);

ExtensionManagementUtility::addPiFlexFormValue(
    '',
    'FILE:EXT:myext/Configuration/FlexForm.xml',
    $ctypeKey,
);
Copied!

Within the FlexForm use settings. as prefix for the identifier of your fields. Any field prefixed with settings. will be automatically available in the controller's settings array ($this->settings['someSetting']) and in the Fluid templates as variable {settings.someSetting}. For example:

packages/my_extension/Configuration/FlexForm.xml
<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <sheetTitle>
                    Sheet Title
                </sheetTitle>
                <type>array</type>
                <el>
                    <settings.someSetting>
                        <label>Some Setting</label>
                        <config>
                            <type>input</type>
                        </config>
                    </settings.someSetting>
                    <settings.anotherSetting>
                        <label>Another Setting</label>
                        <config>
                            <type>input</type>
                        </config>
                    </settings.anotherSetting>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>
Copied!

For an example see the plugin settings of the plugins in extension georgringer/news .

Plain plugins configured by FlexForms

Complex content elements or plain plugins not registered via Extbase can use FlexForms for configuration as well. Plain plugins can be configured with FlexForms in a similar fashion to Extbase plugins:

packages/my_extension/Configuration/TCA/Overrides/tt_content.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

$ctypeKey = 'my_plugin';

// Plain plugin without Extbase controller
ExtensionManagementUtility::addPlugin(
    [
        'My Plugin Title',
        $ctypeKey,
        'my-extension-icon',
    ],
);

ExtensionManagementUtility::addToAllTCAtypes(
    'tt_content',
    '--div--;Configuration,pi_flexform,',
    $ctypeKey,
    'after:subheader',
);

ExtensionManagementUtility::addPiFlexFormValue(
    '',
    'FILE:EXT:myext/Configuration/FlexForm.xml',
    $ctypeKey,
);
Copied!

Plain plugins can use any name scheme for the identifiers that they desire.

When a content element containing a FlexForm is saved the settings are written as XML to column tt_content.pi_flexform in the according database record.

See also: Read FlexForms values in PHP.

For example the carousel of the extension bk2k/bootstrap-package uses FlexForms for its configuration.