ModifyEditFileFormDataEvent

New in version 12.1: This event can be used as an improved alternative for the removed $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'] hook.

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 in your extension's Services.yaml:

EXT:my_package/Configuration/Services.yaml
MyVendor\MyPackage\EventListener\ModifyEditFileFormDataEventListener:
    tags:
        - name: event.listener
          identifier: 'my-package/modify-edit-file-form-data-event-listener'

The corresponding event listener class:

EXT:my_package/Classes/EventLister/ModifyEditFileFormDataEventListener.php
 use TYPO3\CMS\Filelist\Event\ModifyEditFileFormDataEvent;

 final class ModifyEditFileFormDataEventListener
 {
     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);
     }
 }

API

class 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()
Return type

array

setFormData(array $formData)
Parameters
  • $formData (array) -- the formData

getFile()
Return type

TYPO3\CMS\Core\Resource\FileInterface

getRequest()
Return type

Psr\Http\Message\ServerRequestInterface