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
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\FileList\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Filelist\Event\ModifyEditFileFormDataEvent;
#[AsEventListener(
identifier: 'my-extension/modify-edit-file-form-data',
)]
final readonly 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);
}
}
New in version 13.0
The PHP attribute \TYPO3\
has been
introduced to tag a PHP class as an event listener. Alternatively, or if you
need to be compatible with older TYPO3 versions, you can also register an
event listener via the Configuration/
file. Switch to
an older version of this page for an example or have a look at the section
Implementing an event listener in your extension.