itemsProcessors: Processing of items for select, check and radio type fields 

The TCA option itemsProcessors provides a structured and extensible way to process items for select, check, and radio type fields. It supersedes itemsProcFunc by allowing multiple processors to be applied in a defined order using a strictly typed API.

The option is defined as an array of processors. Each processor is executed sequentially based on its numerical array key, with lower values executed first. This makes it possible for extensions or integrators to add additional processing steps without replacing existing logic.

itemsProcFunc can still be used, but itemsProcessors is the recommended approach. If both itemsProcFunc and itemsProcessors are configured, both are executed. In that case, itemsProcFunc is executed first.

TCA item processor registration 

EXT:my_extension/Configuration/TCA/my_table.php
<?php

use MyVendor\MyExtension\Processors\SpecialRelationsProcessor;

return
    [
        // ...
        'columns' => [
            'relation' => [
                'label' => 'Relational field',
                'config' => [
                    'type' => 'select',
                    'renderType' => 'selectSingle',
                    'items' => [
                        [
                            'value' => 0,
                            'label' => '',
                        ],
                    ],
                    'foreign_table' => 'some_foreign_table',
                    'itemsProcessors' => [
                        100 => [
                            'class' => SpecialRelationsProcessor::class,
                            'parameters' => [
                                'foo' => 'bar',
                            ],
                        ],
                        50 => [
                            'class' => SpecialRelationsProcessor2::class,
                        ],
                    ],
                ],
            ],
        ],
    ];
Copied!

In this example, SpecialRelationsProcessor2 is executed before SpecialRelationsProcessor.

TCA item processor implementation 

All processors must implement the ItemsProcessorInterface .

Processors have two parameters:

  • A SelectItemCollection instance containing the current items.
  • An ItemsProcessorContext instance providing access to table, field, row data, and configuration.

A processor must return a SelectItemCollection . Since items are handled as objects, newly added items can no longer be represented as untyped arrays.

EXT:my_extension/Classes/Processors/SpecialRelationsProcessor.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Processors;

use TYPO3\CMS\Core\DataHandling\ItemsProcessorContext;
use TYPO3\CMS\Core\DataHandling\ItemsProcessorInterface;
use TYPO3\CMS\Core\Schema\Struct\SelectItem;
use TYPO3\CMS\Core\Schema\Struct\SelectItemCollection;

final class SpecialRelationsProcessor implements ItemsProcessorInterface
{
    public function processItems(
        SelectItemCollection $items,
        ItemsProcessorContext $context,
    ): SelectItemCollection {
        $items->add(
            new SelectItem(
                type: 'select',
                label: sprintf('Extra item: %s', $context->processorParameters['foo'] ?? ''),
                value: 42,
            )
        );

        return $items;
    }
}
Copied!

You can add your own parameters to processors. They are exposed via the processor context.

Add parameters via TCA or page TSconfig and access them through $context->processorParameters.

For example, the following item processor configuration:

EXT:my_extension/Configuration/TCA/my_table.php
// ...
100 => [
    'class' => SpecialRelationsProcessor::class,
    'parameters' => [
        'foo' => 'bar',
    ],
],
Copied!

can access $context->processorParameters['foo']. The value can be overridden or extended, for example via a site setting defined in page TSconfig:

EXT:my_extension/Configuration/Sets/MySet/page.tsconfig
TCEFORM.example_table.content.itemsProcessors.100.foo = {$myExtension.bar}
Copied!

Registering item processors in FlexForms 

Registration of processors is also possible inside FlexForms:

EXT:my_package/Configuration/FlexForms/SomeForm.xml
<some_selector>
    <label>Choice</label>
    <config>
        <type>select</type>
        <renderType>selectSingle</renderType>
        <itemsProcessors>
            <numIndex index="100">
                <class>MyVendor\MyPackage\Processors\SpecialRelationsProcessor</class>
            </numIndex>
        </itemsProcessors>
    </config>
</some_selector>
Copied!