ModifyInlineElementControlsEvent 

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: Enable and add controls of inline elements 

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\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
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_myextension_control',
        '<a href="/some/url" class="btn btn-default t3js-modal-trigger">'
          . $iconFactory->getIcon('my-icon-identifier', IconSize::SMALL)->render()
          . '</a>',
      );
    }
  }
}
Copied!

API 

final 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