Feature: #102865 - PSR-14 event for modifying loaded form definition

See forge#102865


A new PSR-14 event \TYPO3\CMS\Form\Mvc\Persistence\Event\AfterFormDefinitionLoadedEvent has been introduced which allows extensions to modify loaded form definitions.

The event is being dispatched after FormPersistenceManager has loaded the definition from either the cache or the filesystem. In latter case, the event is dispatched after FormPersistenceManager has stored the loaded definition in cache. This means, it's always possible to modify the cached version. However, the modified form definition is then overridden by TypoScript, in case a corresponding formDefinitionOverrides exists.

The event features the following methods:

  • getFormDefinition() - Returns the loaded form definition

  • setFormDefinition() - Allows to modify the loaded form definition

  • getPersistenceIdentifier() - Returns the persistence identifier, used to load the definition

  • getCacheKey() - Returns the calculated cache key


The event listener class, using the PHP attribute #[AsEventListener] for registration:

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Form\Mvc\Persistence\Event\AfterFormDefinitionLoadedEvent;

final class AfterFormDefinitionLoadedEventListener
    public function __invoke(AfterFormDefinitionLoadedEvent $event): void
        if ($event->getPersistenceIdentifier() === '1:/form_definitions/contact.form.yaml') {
            $formDefinition = $event->getFormDefinition();
            $formDefinition['label'] = 'some new label';


Using the new PSR-14 event, it's now possible to fully modify any loaded form definition, before being overridden by TypoScript.