FlexForm field

Renders a FlexForm element. Essentially, this consists in a hierarchically organized set of fields which will have their values saved into a single field in the database, stored as XML.

The general idea is: There is a data structure that defines which and how single fields should be displayed, re-using all the TCA column type possibilities. The actual values of single fields are then stored in an XML representation within this "flex" field.

Properties of the TCA column type flex

Deprecated since version 12.4

The configuration options ds_tableField, ds_pointerField_searchParent_subField and ds_pointerField_searchParent will not handled anymore with TYPO3 v13. Use the Events to replace their logic if needed.

Name Type Scope
boolean Proc.
array Display / Proc.
string Display / Proc.
string Display / Proc.
string Display / Proc.
string Display / Proc.
array
array
array
boolean Display
behaviour
allowLanguageSynchronization
Type
boolean
Default
false
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['behaviour']['allowLanguageSynchronization']
Scope
Proc.

Allows an editor to select in a localized record whether the value is copied over from default or source language record, or if the field has an own value in the localization. If set to true and if the table supports localization and if a localized record is edited, this setting enables FieldWizard LocalizationStateSelector: Two or three radio buttons shown below the field input. The state of this is stored in a json encoded array in the database table called l10n_state. It tells the DataHandler which fields of the localization records should be kept in sync if the underlying default or source record changes.

EXT:my_extension/Configuration/TCA/Overrides/someTable.php
<?php

$flexField = [
    'config' => [
        'type' => 'flex',
        'behaviour' => [
            'allowLanguageSynchronization' => true,
        ],
    ],
];
Copied!
ds
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display / Proc.

Data Structure(s) defined in an array.

Each key is a value that can be pointed to by ds_pointerField. Default key is "default" which is what you should use if you do not have a ds_pointerField value of course.

If you specified more than one ds_pointerField, the keys in this "ds" array should contain comma-separated value pairs where the asterisk * matches all values (see the example below). If you don't need to switch for the second ds_pointerField, it's also possible to use only the first ds_pointerField's value as a key in the "ds" array without necessarily suffixing it with ",*" for a catch-all on the second ds_pointerField.

For each value in the array there are two options:

  • Make a reference to an external XML file
  • Either enter XML directly
Example with XML in external file
EXT:styleguide/Configuration/TCA/tx_styleguide_flex.php
[
    'columns' => [
        'flex_file_1' => [
            'label' => 'flex_file_1 simple flexform in external file',
            'description' => 'field description',
            'config' => [
                'type' => 'flex',
                'ds' => [
                    'default' => 'FILE:EXT:styleguide/Configuration/FlexForms/Simple.xml',
                ],
            ],
        ],
    ],
]
Copied!

The included file:

<T3DataStructure>
    <sheets>
        <sDEF>
            <ROOT>
                <sheetTitle>Sheet Title</sheetTitle>
                <type>array</type>
                <el>
                    <input_1>
                        <label>input_1</label>
                        <config>
                            <type>input</type>
                        </config>
                    </input_1>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>
Copied!
Example with XML directly entered
EXT:styleguide/Configuration/TCA/tx_styleguide_flex.php
[
    'columns' => [
        'flex_2' => [
            'label' => 'flex_2 section container',
            'config' => [
                'type' => 'flex',
                'ds' => [
                    'default' => '
                        <T3DataStructure>
                            <sheets>
                                <sSection>
                                    <ROOT>
                                        <sheetTitle>section</sheetTitle>
                                        <type>array</type>
                                        <el>
                                            <section_1>
                                                <title>section_1</title>
                                                <type>array</type>
                                                <section>1</section>
                                                <el>
                                                    <container_1>
                                                        <type>array</type>
                                                        <title>container_1</title>
                                                        <el>
                                                            <input_1>
                                                                <label>input_1 description</label>
                                                                <description>field description</description>
                                                                <config>
                                                                    <type>input</type>
                                                                </config>
                                                            </input_1>
                                                            <color_1>
                                                                <label>color_1</label>
                                                                <config>
                                                                    <type>color</type>
                                                                    <size>10</size>
                                                                </config>
                                                            </color_1>
                                                        </el>
                                                    </container_1>
                                                    <container_2>
                                                        <type>array</type>
                                                        <title>container_2</title>
                                                        <el>
                                                            <text_1>
                                                                <label>text_1 default "foo"</label>
                                                                <config>
                                                                    <type>text</type>
                                                                    <default>foo</default>
                                                                </config>
                                                            </text_1>
                                                        </el>
                                                    </container_2>
                                                </el>
                                            </section_1>
                                        </el>
                                    </ROOT>
                                </sSection>
                            </sheets>
                        </T3DataStructure>
                    ',
                ],
            ],
        ],
    ],
]
Copied!
ds_pointerField
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display / Proc.

Field name(s) in the record which point to the field where the key for "ds" is found. Up to two field names can be specified comma separated.

ds_pointerField_searchParent
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display / Proc.

Deprecated since version This configuration option will not be handled anymore with TYPO3 v13+.

Beginning with TYPO3 v12 you can migrate to PSR-14 events to manipulate the data structure lookup logic.

Used to search for Data Structure recursively back in the table assuming that the table is a tree table. This value points to the "pid" field.

ds_pointerField_searchParent_subField
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display / Proc.

Deprecated since version This configuration option will not be handled anymore with TYPO3 v13+.

Beginning with TYPO3 v12 you can migrate to PSR-14 events to manipulate the data structure lookup logic.

Points to a field in the "rootline" which may contain a pointer to the "next-level" template.

ds_tableField
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display / Proc.

Deprecated since version This configuration option will not be handled anymore with TYPO3 v13+.

Beginning with TYPO3 v12 you can migrate to PSR-14 events to manipulate the data structure lookup logic.

Contains the value "[table]:[field name]" from which to fetch Data Structure XML.

ds_pointerField is in this case the pointer which should contain the uid of a record from that table.

fieldInformation

For details see fieldInformation.

fieldWizard
defaultLanguageDifferences
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['defaultLanguageDifferences']

For details see defaultLanguageDifferences.

localizationStateSelector
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['localizationStateSelector']

For details see localizationStateSelector.

otherLanguageContent
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['otherLanguageContent']

For details see otherLanguageContent.

readOnly
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['readOnly']
Scope
Display

Renders the field in a way that the user can see the value but cannot edit it.

Defining multiple data structures for different records

There can be multiple data structures defined in TCA and it depends on the configuration and the record which one is chosen. If the ds and ds_pointerField are not sufficient, you can use the Events to manipulate with data structure should be displayed.

Events to manipulate the FlexForm data structure

New in version 12.x

There are appropriate events that allow the manipulation of the data structure lookup logic: