---
title: "Feature: Dispatch ModifyTcaSelectFieldItemsEvent in itemsProcFunc handlers"
manual: "Academic Profiles"
version: "3.0"
permalink: "https://docs.typo3.org/permalink/fgtclb/academic-persons:feature-1783613368@3.0"
source: "Changelog/2.4/Feature-DispatchModifyTcaSelectFieldItemsEventInItemsProcFunc.rst"
rendered: "2026-10-26T17:55:22+00:00"
---

# Feature: Dispatch `ModifyTcaSelectFieldItemsEvent` in `itemsProcFunc` handlers {#feature-1783613368}

## Description {#description}

The following `itemsProcFunc` handlers provided by `EXT:academic_persons` now
dispatch the shared PSR-14 event
`\FGTCLB\AcademicBase\Event\ModifyTcaSelectFieldItemsEvent`:

-   `\FGTCLB\AcademicPersons\Backend\FormEngine\ContractItems`
-   `\FGTCLB\AcademicPersons\Backend\FormEngine\ProfileShowFieldsItems`

Previously the shipped select items could only be adjusted by adding items
directly (without influence on the ordering) or by implementing a custom
`itemsProcFunc` replacing the shipped one. Both ways were neither convenient
nor testable.

With the dispatched event, projects can modify the available select items of
the backend form through a single PSR-14 event listener, instead of dealing
with a dozen dedicatedly named events for the same purpose. The event carries
the complete `itemsProcFunc` parameters, including `table`, `field`
and `items`. For a FlexForm field, `field` is the name of the
FlexForm element, for example `settings.showFields`.

### Example {#example}

`\TYPO3\CMS\Core\Attribute\AsEventListener` does not exist on TYPO3 v12,
so a listener that has to run on both supported versions is registered in
[`Configuration/Services.yaml`](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/Configuration/ServicesYaml.html#file-extension-configuration-services-yaml):

**EXT:my_ext/Configuration/Services.yaml**

```yaml
services:
  MyVendor\MyExt\EventListener\ModifyTcaSelectFieldItemsEventListener:
    tags:
      - name: event.listener
        identifier: 'my-ext/modify-academic-persons-tca-select-items'
```

**EXT:my_ext/Classes/EventListener/ModifyTcaSelectFieldItemsEventListener.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExt\EventListener;

use FGTCLB\AcademicBase\Event\ModifyTcaSelectFieldItemsEvent;

final class ModifyTcaSelectFieldItemsEventListener
{
    public function __invoke(ModifyTcaSelectFieldItemsEvent $event): void
    {
        $tableName = $event->getParameters()['table'];
        $fieldName = $event->getParameters()['field'];
        if ($tableName !== 'tt_content') {
            // Not the table we want to handle. Skip.
            return;
        }
        if ($fieldName === 'settings.showFields') {
            $this->modifyPersonsShowFieldsSelectItems($event);
        }
        if ($fieldName === 'settings.selectedContracts') {
            $this->modifyPersonsContractSelectItems($event);
        }
    }

    private function modifyPersonsShowFieldsSelectItems(
        ModifyTcaSelectFieldItemsEvent $event,
    ): void {
        // This project does not show rooms, so the option is not offered.
        $parameters = $event->getParameters();
        $parameters['items'] = array_values(array_filter(
            $parameters['items'],
            static fn(array $item): bool => ($item['value'] ?? null) !== 'contracts.room',
        ));
        $event->setParameters($parameters);
    }

    private function modifyPersonsContractSelectItems(
        ModifyTcaSelectFieldItemsEvent $event,
    ): void {
        $parameters = $event->getParameters();
        $parameters['items'][] = [
            'label' => 'LLL:EXT:my_ext/Resources/Private/Language/locallang_be.xlf:custom_contract',
            'value' => 10,
        ];
        $event->setParameters($parameters);
    }
}
```

## Impact {#impact}

Nothing changes for an installation without a listener: the handlers deliver
the items they delivered before. A listener receives the items after the
handler added its own, and what it hands back with `setParameters()` is
what the backend form offers.

## Affected Installations {#affected-installations}

Installations that adjust the items of the contract select or of the
**Show only selected Fields** select of the persons plugins.
