BeforeLiveSearchFormIsBuiltEvent
The PSR-14 event
\Before
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
<?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']);
}
}
API
- class BeforeLiveSearchFormIsBuiltEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Search\ Event\ Before Live Search Form Is Built Event
PSR-14 event to add, change or remove data for the live search form
Note
set
becomes handy to provide additional data to
the template without the need to cross class ("xclass") the controller. The
additional view data can be used in an overridden backend template of the
live search form.