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']

This event 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 in your extensions' Services.yaml:

my_extension/Configuration/Services.yaml
MyVendor\MyPackage\Backend\MyEventListener:
  tags:
    - name: event.listener
      identifier: 'my-package/backend/modify-enabled-controls'
      method: 'modifyEnabledControls'
    - name: event.listener
      identifier: 'my-package/backend/modify-controls'
      method: 'modifyControls'

The corresponding event listener class:

use TYPO3\CMS\Backend\Form\Event\ModifyInlineElementEnabledControlsEvent;
use TYPO3\CMS\Backend\Form\Event\ModifyInlineElementControlsEvent;
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 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

Return type

array

setControls(array $controls)

Overwrite the controls

Parameters
  • $controls (array) -- the controls

getControl(string $identifier)

Returns the markup for the requested control

Parameters
  • $identifier (string) -- the identifier

Return type

string

setControl(string $identifier, string $markup)

Set a control with the given identifier and markup IMPORTANT: Overwrites an existing control with the same identifier

Parameters
  • $identifier (string) -- the identifier

  • $markup (string) -- the markup

hasControl(string $identifier)

Returns whether a control exists for the given identifier

Parameters
  • $identifier (string) -- the identifier

Return type

bool

removeControl(string $identifier)

Removes a control from the inline element, if it exists

Parameters
  • $identifier (string) -- the identifier

Return type

bool

Returns

Whether the control could be removed

getElementData()

Returns the whole element data

Return type

array

getRecord()

Returns the current record of the controls are created for

Return type

array

getParentUid()

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

Return type

string

getForeignTable()

Returns the table (foreign_table) the controls are created for

Return type

string

getFieldConfiguration()

Returns the TCA configuration of the inline record field

Return type

array

isVirtual()

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

Return type

bool