BeforeLiveSearchFormIsBuiltEvent

The PSR-14 event \BeforeLiveSearchFormIsBuiltEvent can be used to modify the form data for the backend live search.

This event allows extension developer to add, change or remove hints to the live search form or change the search demand object.

Furthermore, additional view data can be provided and used in a overridden module action template. This avoids the need for using the XCLASS technique to provide additional data.

Example

EXT:my_extension/Classes/Backend/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyPackage\Backend\Search\EventListener;

use TYPO3\CMS\Backend\Search\Event\BeforeLiveSearchFormIsBuiltEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;

final class BeforeLiveSearchFormIsBuiltEventListener
{
    #[AsEventListener('my-package/backend/search/modify-live-search-form-data')]
    public function __invoke(BeforeLiveSearchFormIsBuiltEvent $event): void
    {
        $event->addHints(...[
            'LLL:EXT:my-package/Resources/Private/Language/locallang.xlf:identifier',
        ]);
        $event->setAdditionalViewData(['myVariable' => 'some data']);
    }
}
Copied!

API

class BeforeLiveSearchFormIsBuiltEvent
Fully qualified name
\TYPO3\CMS\Backend\Search\Event\BeforeLiveSearchFormIsBuiltEvent

PSR-14 event to add, change or remove data for the live search form

getHints ( )
Returns
list<non-empty-string>
setHints ( array $hints)
param $hints

the hints

addHint ( string $label)
param $label

the label

addHints ( string ...$labels)
param $labels

the labels

getRequest ( )
Returns
\Psr\Http\Message\ServerRequestInterface
getSearchDemand ( )
Returns
\TYPO3\CMS\Backend\Search\LiveSearch\SearchDemand\SearchDemand
setSearchDemand ( \TYPO3\CMS\Backend\Search\LiveSearch\SearchDemand\SearchDemand $searchDemand)
param $searchDemand

the searchDemand

getAdditionalViewData ( )
Returns
array<non-empty-string,mixed>
setAdditionalViewData ( array $viewData)
param $viewData

the viewData