ModifyInlineElementControlsEvent
New in version 12.0
This event, together with ModifyInlineElementEnabledControlsEvent,
serves as a more powerful and flexible replacement
for the removed hook $GLOBALS
The PSR-14 event \TYPO3\
is called after the markup for all enabled controls has been generated. It
can be used to either change the markup of a control, to add a new control
or to completely remove a control.
Example
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Backend\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/backend/modify-enabled-controls'
method: 'modifyEnabledControls'
- name: event.listener
identifier: 'my-extension/backend/modify-controls'
method: 'modifyControls'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Form\Event\ModifyInlineElementControlsEvent;
use TYPO3\CMS\Backend\Form\Event\ModifyInlineElementEnabledControlsEvent;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
final class MyEventListener
{
public function modifyEnabledControls(ModifyInlineElementEnabledControlsEvent $event): void
{
// Enable a control depending on the foreign table
if ($event->getForeignTable() === 'sys_file_reference' && $event->isControlEnabled('sort')) {
$event->enableControl('sort');
}
}
public function modifyControls(ModifyInlineElementControlsEvent $event): void
{
// Add a custom control depending on the parent table
if ($event->getElementData()['inlineParentTableName'] === 'tt_content') {
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$event->setControl(
'tx_my_control',
'<a href="/some/url" class="btn btn-default t3js-modal-trigger">'
. $iconFactory->getIcon('my-icon-identifier', Icon::SIZE_SMALL)->render()
. '</a>',
);
}
}
}
API
- class ModifyInlineElementControlsEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Form\ Event\ Modify Inline Element Controls Event
Listeners to this Event will be able to modify the controls of an inline element
- getControl ( string $identifier)
-
Returns the markup for the requested control
- param $identifier
-
the identifier
- Returns
-
string
- setControl ( string $identifier, string $markup)
-
Set a control with the given identifier and markup IMPORTANT: Overwrites an existing control with the same identifier
- param $identifier
-
the identifier
- param $markup
-
the markup
- hasControl ( string $identifier)
-
Returns whether a control exists for the given identifier
- param $identifier
-
the identifier
- Returns
-
bool