ModifyInlineElementControlsEvent

New in version 12.0

This event, together with ModifyInlineElementEnabledControlsEvent, serves as a more powerful and flexible replacement for the removed hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook']

The PSR-14 event \TYPO3\CMS\Backend\Form\Event\ModifyInlineElementControlsEvent 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

EXT:my_extension/Classes/Backend/EventListener/MyEventListener.php
<?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\Attribute\AsEventListener;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;

#[AsEventListener(
    identifier: 'my-extension/backend/modify-enabled-controls',
    method: 'modifyEnabledControls',
)]
#[AsEventListener(
    identifier: 'my-extension/backend/modify-controls',
    method: 'modifyControls',
)]
final readonly 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>',
            );
        }
    }
}
Copied!

New in version 13.0

The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener has been introduced to tag a PHP class as an event listener. Alternatively, or if you need to be compatible with older TYPO3 versions, you can also register an event listener via the Configuration/Services.yaml file. Switch to an older version of this page for an example or have a look at the section Implementing an event listener in your extension.

API

class ModifyInlineElementControlsEvent
Fully qualified name
\TYPO3\CMS\Backend\Form\Event\ModifyInlineElementControlsEvent

Listeners to this Event will be able to modify the controls of an inline element

getControls ( )

Returns all controls with their markup

Returns
array
setControls ( array $controls)

Overwrite the controls

param $controls

the controls

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
removeControl ( string $identifier)

Removes a control from the inline element, if it exists

param $identifier

the identifier

Return description

Whether the control could be removed

Returns
bool
getElementData ( )

Returns the whole element data

Returns
array
getRecord ( )

Returns the current record of the controls are created for

Returns
array
getParentUid ( )

Returns the uid of the parent (embedding) record (uid or NEW...)

Returns
string
getForeignTable ( )

Returns the table (foreign_table) the controls are created for

Returns
string
getFieldConfiguration ( )

Returns the TCA configuration of the inline record field

Returns
array
isVirtual ( )

Returns whether the current records is only virtually shown and not physically part of the parent record

Returns
bool