ModifyEditFileFormDataEvent

New in version 12.1

The PSR-14 event \TYPO3\CMS\Filelist\Event\ModifyEditFileFormDataEvent 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.yaml:

EXT:my_extension/Configuration/Services.yaml
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'
Copied!

Read how to configure dependency injection in extensions.

The corresponding event listener class:

EXT:my_extension/Classes/FileList/EventListener/MyEventListener.php
<?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);
    }
}
Copied!

API

class ModifyEditFileFormDataEvent
Fully qualified name
\TYPO3\CMS\Filelist\Event\ModifyEditFileFormDataEvent

Listeners to this event are be able to modify the form data, used to render the edit file form in the filelist module.

getFormData ( )
Returns
array
setFormData ( array $formData)
param $formData

the formData

getFile ( )
Returns
\TYPO3\CMS\Core\Resource\FileInterface
getRequest ( )
Returns
\Psr\Http\Message\ServerRequestInterface