FlexForms
FlexForms can be used to store data within an XML structure inside a single DB column.
Attention
Changed in version 13.0
The superfluous tag
TCEforms
was removed and is not evaluated
anymore. All
TCEforms
tags must be removed. Otherwise the
FlexForm is displayed broken in the backend records.
Extbase plugin settings as FlexForm
FlexForms are commonly used to configure Extbase plugins:
<?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,
);
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
) and
in the Fluid templates as variable {settings.
. For example:
<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>
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:
<?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,
);
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_
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.