ModifyEditFileFormDataEvent
New in version 12.1
This event can be used as an improved alternative for the removed
$GLOBALS
hook.
The PSR-14 event \TYPO3\
allows to modify the form data, used to render the file edit form in the
File > Filelist module using
FormEngine data compiling.
Example
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\FileList\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/modify-edit-file-form-data'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\FileList\EventListener;
use TYPO3\CMS\Filelist\Event\ModifyEditFileFormDataEvent;
final class MyEventListener
{
public function __invoke(ModifyEditFileFormDataEvent $event): void
{
// Get current form data
$formData = $event->getFormData();
// Change TCA "renderType" based on the file extension
$fileExtension = $event->getFile()->getExtension();
if ($fileExtension === 'ts') {
$formData['processedTca']['columns']['data']['config']['renderType'] = 'tsRenderer';
}
// Set updated form data
$event->setFormData($formData);
}
}