ModifyNewRecordCreationLinksEvent
New in version 14.0
See Feature: #99459 - Respect record type while creating new records.
The PSR-14 event
\TYPO3\
allows the
New record component in the Contents > Records module
to be modified.
Table of contents
Example: Customizing the create new record wizard
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\EventListener;
use TYPO3\CMS\Backend\Controller\Event\ModifyNewRecordCreationLinksEvent;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\IconSize;
final readonly class CustomizeNewRecordWizardEventListener
{
public function __construct(
private IconFactory $iconFactory,
private UriBuilder $uriBuilder,
) {}
#[AsEventListener]
public function __invoke(ModifyNewRecordCreationLinksEvent $event): void
{
// Add a custom creation group
$customGroup = [
'title' => 'Custom Records',
'icon' => $this->iconFactory->getIcon('apps-pagetree-category')->render(),
'items' => [
'tx_myext_domain_model_item' => [
'url' => (string)$this->uriBuilder->buildUriFromRoute('record_edit', [
'edit' => ['tx_myext_domain_model_item' => [$event->pageId => 'new']],
'returnUrl' => $event->request->getAttribute('normalizedParams')->getRequestUri(),
]),
'icon' => $this->iconFactory->getIconForRecord('tx_myext_domain_model_item', []),
'label' => 'Custom Item',
],
],
];
// Add the custom group to the existing structure
$event->groupedCreationLinks['custom'] = $customGroup;
// Modify existing groups - for example, remove specific items
if (isset($event->groupedCreationLinks['system']['items']['sys_template'])) {
unset($event->groupedCreationLinks['system']['items']['sys_template']);
}
// Add custom types to an existing table
if (isset($event->groupedCreationLinks['content']['items']['sys_note'])) {
$event->groupedCreationLinks['content']['items']['sys_note']['types'] = [
'important' => [
'url' => (string)$this->uriBuilder->buildUriFromRoute('record_edit', [
'edit' => ['sys_note' => [$event->pageId => 'new']],
'defVals' => ['sys_note' => ['category' => '1']],
'returnUrl' => $event->request->getAttribute('normalizedParams')->getRequestUri(),
]),
'icon' => $this->iconFactory->getIcon('status-dialog-warning', IconSize::SMALL),
'label' => 'Important Note',
],
'info' => [
'url' => (string)$this->uriBuilder->buildUriFromRoute('record_edit', [
'edit' => ['sys_note' => [$event->pageId => 'new']],
'defVals' => ['sys_note' => ['category' => '0']],
'returnUrl' => $event->request->getAttribute('normalizedParams')->getRequestUri(),
]),
'icon' => $this->iconFactory->getIcon('status-dialog-information', IconSize::SMALL),
'label' => 'Information Note',
],
];
}
}
}
API of ModifyNewRecordCreationLinksEvent
The event provides access to:
$event->grouped- The complete structure of creation linksCreation Links $event->page- The current page's TSconfig arrayTS $event->page- The current page IDId $event->request- The current server request object
This allows for comprehensive customization while maintaining backward compatibility with existing customizations.
- class ModifyNewRecordCreationLinksEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Controller\ Event\ Modify New Record Creation Links Event
Event to modify the grouped links as result of NewRecordController
Structure (array):
- "content" => [
- "title" => "Content", "icon" => "<img...>" "items" => [ "sys_note" => [ [ "url" => "...", "icon" => "...", "label" => "...", ], ], "sys_file_collection" => [ [ "icon" => "...", "label" => "...", "types" => [ "static" => [ 'url' => "...", 'icon' => "...", 'label' => "...", ], "folder" => [ 'url' => "...", 'icon' => "...", 'label' => "...", ], ], ], ], ],
], "system" => [ "title" => "System Records", "icon" => "<img...>" "items" => [ "sys_template" => [ [ "url" => "...", "icon" => "...", "label" => "...", ], ], "backend_layout" => [ [ "url" => "...", "icon" => "...", "label" => "...", ], ], ], ],
Datastructure used in the ModifyNewRecordCreationLinksEvent
The event works with a nested array structure representing grouped creation links:
[
'content' => [
'title' => 'Content',
'icon' => '<img src="..." />',
'items' => [
'sys_file_collection' => [
'label' => 'File Collection',
'icon' => '<typo3-backend-icon ...>',
'types' => [
'static' => [
'url' => '/typo3/record/edit?edit[sys_file_collection][1]=new&defVals[sys_file_collection][type]=static',
'icon' => '<typo3-backend-icon ...>',
'label' => 'Static File Collection'
],
'folder' => [
'url' => '/typo3/record/edit?edit[sys_file_collection][1]=new&defVals[sys_file_collection][type]=folder',
'icon' => '<typo3-backend-icon ...>',
'label' => 'Folder from Storage'
]
]
]
]
],
'pages' => [
'title' => 'Create New Page',
'icon' => '<typo3-backend-icon ...>',
'items' => [
'inside' => [
'label' => 'Page (inside)',
'icon' => '<typo3-backend-icon ...>',
'types' => [
'1' => [
'url' => '/typo3/record/edit?edit[pages][1]=new&defVals[pages][doktype]=1',
'icon' => '<typo3-backend-icon ...>',
'label' => 'Standard Page'
],
'254' => [
'url' => '/typo3/record/edit?edit[pages][1]=new&defVals[pages][doktype]=254',
'icon' => '<typo3-backend-icon ...>',
'label' => 'Folder'
]
]
]
]
]
]