TYPO3 Logo
TYPO3 Explained
Options
Give feedback View source How to edit Edit on GitHub Full documentation (single file)

TYPO3 Explained

  • Introduction
  • API A-Z
    • Assets
    • Authentication
      • CSRF-like request token handling
      • Multi-factor authentication
    • Autoloading
      • ComposerClassLoader
    • Backend APIs
      • Access control
        • Users and groups
        • Password reset functionality
        • Roles
        • Options
        • Other Options
        • File mounts
        • Backend users module
      • Backend modules API
        • Modules.php
          • 3rd level
          • Toplevel
        • Backend GUI
        • DocHeaderComponent
        • ModuleData
        • ModuleInterface
        • ModuleProvider
        • ModuleTemplate
        • ModuleTemplateFactory
        • TypoScript
        • Sudo mode
      • JavaScript
        • ES6 in the TYPO3 Backend
        • RequireJS (Deprecated)
          • Use RequireJS in your own extension
          • Dependency handling
          • Loading your own or other RequireJS modules
          • Shim Library to Use it as Own RequireJS Modules
        • Client-side templating
        • Various JavaScript modules
          • Modals
          • Multi-step wizard
          • DocumentService (jQuery.ready substitute)
          • SessionStorage wrapper
        • Ajax request
        • Event API
        • Navigation via JavaScript
        • JavaScript form helpers
      • Ajax
      • Backend layout
      • Backend routing
      • Backend user object
      • Broadcast channels
      • Button components
      • Clipboard
      • Context menus
      • Custom Permissions
      • LoginProvider
      • UriBuilder
    • Bitsets & Enumerations
      • How to use enumerations
      • How to use bitsets
    • Caching
      • Quick start for integrators
      • Configuration
      • Caching framework architecture
      • Cache frontends
      • Developer information
    • System categories
    • Commands
      • List Core commands
      • Tutorial
    • Content Elements & Plugins
      • Create a custom content element type
      • Custom data processors
      • Create plugins
      • Configure custom backend preview for content element
      • Add content elements to the Content Element Wizard
      • Best practices
    • Content Security Policy
    • Context API and aspects
    • Country API
    • Cropping images
      • General Configuration
      • Crop variants configuration per content element
    • Database
      • Introduction
      • Configuration
      • Database structure
      • Upgrade table and field definitions
      • Basic create, read, update, and delete operations (CRUD)
      • Class overview
      • ConnectionPool
      • Query builder
      • Connection
      • Expression builder
      • Restriction builder
      • Result
      • Driver middlewares
      • Various tips and tricks
    • Database records
    • DataHandler
      • Introduction
      • DataHandler basics
      • Using the DataHandler in scripts
      • The "/record/commit" route
    • Debugging
    • Dependency injection
    • Deprecation
    • Environment
    • Error and exception handling
      • Configuration
      • Error Handler
      • Production exception handler
      • Debug exception handler
      • Examples
      • How to extend the error and exception handling
    • Events and hooks
      • Extending the TYPO3 Core
      • Event dispatcher (PSR-14 events)
      • Event list
        • Backend
          • AfterBackendPageRenderEvent
          • AfterFormEnginePageInitializedEvent
          • AfterHistoryRollbackFinishedEvent
          • AfterPageColumnsSelectedForLocalizationEvent
          • AfterPagePreviewUriGeneratedEvent
          • AfterPageTreeItemsPreparedEvent
          • AfterRecordSummaryForLocalizationEvent
          • BeforeFormEnginePageInitializedEvent
          • BeforeHistoryRollbackStartEvent
          • BeforeModuleCreationEvent
          • BeforePagePreviewUriGeneratedEvent
          • BeforeSearchInDatabaseRecordProviderEvent
          • CustomFileControlsEvent
          • IsContentUsedOnPageLayoutEvent
          • IsFileSelectableEvent
          • ModifyAllowedItemsEvent
          • ModifyButtonBarEvent
          • ModifyClearCacheActionsEvent
          • ModifyDatabaseQueryForContentEvent
          • ModifyDatabaseQueryForRecordListingEvent
          • ModifyEditFormUserAccessEvent
          • ModifyFileReferenceControlsEvent
          • ModifyFileReferenceEnabledControlsEvent
          • ModifyGenericBackendMessagesEvent
          • ModifyImageManipulationPreviewUrlEvent
          • ModifyInlineElementControlsEvent
          • ModifyInlineElementEnabledControlsEvent
          • ModifyLinkExplanationEvent
          • ModifyLinkHandlersEvent
          • ModifyNewContentElementWizardItemsEvent
          • ModifyPageLayoutContentEvent
          • ModifyPageLayoutOnLoginProviderSelectionEvent
          • ModifyQueryForLiveSearchEvent
          • ModifyRecordListHeaderColumnsEvent
          • ModifyRecordListRecordActionsEvent
          • ModifyRecordListTableActionsEvent
          • ModifyResultItemInLiveSearchEvent
          • PageContentPreviewRenderingEvent
          • RenderAdditionalContentToRecordListEvent
          • SwitchUserEvent
          • SystemInformationToolbarCollectorEvent
        • Core
          • Authentication
            • AfterGroupsResolvedEvent
            • AfterUserLoggedInEvent
            • AfterUserLoggedOutEvent
            • BeforeRequestTokenProcessedEvent
            • BeforeUserLogoutEvent
            • LoginAttemptFailedEvent
          • Cache
            • CacheFlushEvent
            • CacheWarmupEvent
          • Configuration
            • AfterFlexFormDataStructureIdentifierInitializedEvent
            • AfterFlexFormDataStructureParsedEvent
            • AfterTcaCompilationEvent
            • BeforeFlexFormDataStructureIdentifierInitializedEvent
            • BeforeFlexFormDataStructureParsedEvent
            • ModifyLoadedPageTsConfigEvent
            • SiteConfigurationBeforeWriteEvent
            • SiteConfigurationLoadedEvent
          • Core
            • BootCompletedEvent
          • Database
            • AlterTableDefinitionStatementsEvent
          • DataHandling
            • AppendLinkHandlerElementsEvent
            • IsTableExcludedFromReferenceIndexEvent
          • Domain
            • AfterRecordLanguageOverlayEvent
            • BeforePageLanguageOverlayEvent
            • BeforeRecordLanguageOverlayEvent
            • RecordAccessGrantedEvent
          • Html
            • BrokenLinkAnalysisEvent
          • Mail
            • AfterMailerInitializationEvent
            • AfterMailerSentMessageEvent
            • BeforeMailerSentMessageEvent
          • Package
            • AfterPackageActivationEvent
            • AfterPackageDeactivationEvent
            • BeforePackageActivationEvent
            • PackagesMayHaveChangedEvent
          • Page
            • BeforeJavaScriptsRenderingEvent
            • BeforeStylesheetsRenderingEvent
          • Password policy
            • EnrichPasswordValidationContextDataEvent
          • Resource
            • AfterDefaultUploadFolderWasResolvedEvent
            • AfterFileAddedEvent
            • AfterFileAddedToIndexEvent
            • AfterFileCommandProcessedEvent
            • AfterFileContentsSetEvent
            • AfterFileCopiedEvent
            • AfterFileCreatedEvent
            • AfterFileDeletedEvent
            • AfterFileMarkedAsMissingEvent
            • AfterFileMetaDataCreatedEvent
            • AfterFileMetaDataDeletedEvent
            • AfterFileMetaDataUpdatedEvent
            • AfterFileMovedEvent
            • AfterFileProcessingEvent
            • AfterFileRemovedFromIndexEvent
            • AfterFileRenamedEvent
            • AfterFileReplacedEvent
            • AfterFileUpdatedInIndexEvent
            • AfterFolderAddedEvent
            • AfterFolderCopiedEvent
            • AfterFolderDeletedEvent
            • AfterFolderMovedEvent
            • AfterFolderRenamedEvent
            • AfterResourceStorageInitializationEvent
            • AfterVideoPreviewFetchedEvent
            • BeforeFileAddedEvent
            • BeforeFileContentsSetEvent
            • BeforeFileCopiedEvent
            • BeforeFileCreatedEvent
            • BeforeFileDeletedEvent
            • BeforeFileMovedEvent
            • BeforeFileProcessingEvent
            • BeforeFileRenamedEvent
            • BeforeFileReplacedEvent
            • BeforeFolderAddedEvent
            • BeforeFolderCopiedEvent
            • BeforeFolderDeletedEvent
            • BeforeFolderMovedEvent
            • BeforeFolderRenamedEvent
            • BeforeResourceStorageInitializationEvent
            • EnrichFileMetaDataEvent
            • GeneratePublicUrlForResourceEvent
            • ModifyFileDumpEvent
            • ModifyIconForResourcePropertiesEvent
            • SanitizeFileNameEvent
          • Security
            • InvestigateMutationsEvent
            • PolicyMutatedEvent
          • Tree
            • ModifyTreeDataEvent
          • TypoScript
            • AfterTemplatesHaveBeenDeterminedEvent
            • EvaluateModifierFunctionEvent
        • Extbase
          • Configuration
            • BeforeFlexFormConfigurationOverrideEvent
          • Mvc
            • AfterRequestDispatchedEvent
            • BeforeActionCallEvent
          • Persistence
            • AfterObjectThawedEvent
            • EntityAddedToPersistenceEvent
            • EntityPersistedEvent
            • EntityRemovedFromPersistenceEvent
            • EntityUpdatedInPersistenceEvent
            • ModifyQueryBeforeFetchingObjectDataEvent
            • ModifyResultAfterFetchingObjectDataEvent
        • ExtensionManager
          • AfterExtensionDatabaseContentHasBeenImportedEvent
          • AfterExtensionFilesHaveBeenImportedEvent
          • AfterExtensionStaticDatabaseContentHasBeenImportedEvent
          • AvailableActionsForExtensionEvent
        • Filelist
          • ModifyEditFileFormDataEvent
          • ProcessFileListActionsEvent
        • Frontend
          • AfterCacheableContentIsGeneratedEvent
          • AfterCachedPageIsPersistedEvent
          • AfterLinkIsGeneratedEvent
          • AfterPageAndLanguageIsResolvedEvent
          • AfterPageWithRootLineIsResolvedEvent
          • BeforePageIsResolvedEvent
          • FilterMenuItemsEvent
          • ModifyCacheLifetimeForPageEvent
          • ModifyHrefLangTagsEvent
          • ModifyPageLinkConfigurationEvent
          • ModifyResolvedFrontendGroupsEvent
          • ShouldUseCachedPageDataIfAvailableEvent
        • FrontendLogin
          • BeforeRedirectEvent
          • LoginConfirmedEvent
          • LoginErrorOccurredEvent
          • LogoutConfirmedEvent
          • ModifyLoginFormViewEvent
          • PasswordChangeEvent
          • SendRecoveryEmailEvent
        • Impexp
          • BeforeImportEvent
        • Info
          • ModifyInfoModuleContentEvent
        • Install
          • ModifyLanguagePackRemoteBaseUrlEvent
          • ModifyLanguagePacksEvent
        • Linkvalidator
          • BeforeRecordIsAnalyzedEvent
          • ModifyValidatorTaskEmailEvent
        • Lowlevel
          • ModifyBlindedConfigurationOptionsEvent
        • Redirects
          • AfterAutoCreateRedirectHasBeenPersistedEvent
          • BeforeRedirectMatchDomainEvent
          • ModifyAutoCreateRedirectRecordBeforePersistingEvent
          • ModifyRedirectManagementControllerViewDataEvent
          • RedirectWasHitEvent
          • SlugRedirectChangeItemCreatedEvent
        • Seo
          • ModifyUrlForCanonicalTagEvent
        • Setup
          • AddJavaScriptModulesEvent
        • Workspaces
          • AfterCompiledCacheableDataForWorkspaceEvent
          • AfterDataGeneratedForWorkspaceEvent
          • AfterRecordPublishedEvent
          • GetVersionedDataEvent
          • ModifyVersionDifferencesEvent
          • SortVersionedDataEvent
      • Hooks
      • JavaScript Event API
        • Regular event
        • Debounce event
        • Throttle event
        • RequestAnimationFrame event
    • File abstraction
      • Basic concepts
      • Architecture
        • Overview
        • Folders
        • Database structure
        • Components
        • PSR-14 events
      • Administration
        • Permissions
        • File storages
        • Maintenance
      • Using FAL
        • Using FAL in the frontend
        • TCA definition
        • The StorageRepository class
        • Working with files, folders and file references
        • Working with collections
        • Searching for files
      • File collections
    • Feature toggle API
    • Custom file processors
    • Flash messages
      • Flash messages API
      • Flash messages in Extbase
      • Flash messages renderer
      • JavaScript-based flash messages (Notification API)
    • FlexForms
      • T3DataStructure
        • Elements
        • Sheet References
        • Parsing a Data Structure
    • Fluid
      • ViewHelper reference
      • Introduction to Fluid
      • Fluid syntax
      • Using Fluid in TYPO3
      • cObject ViewHelper
      • Property additionalAttributes
      • Developing a custom ViewHelper
    • FormEngine
      • Introduction
      • Main rendering workflow
      • Data compiling
      • Rendering
    • Form protection tool
    • Global values
      • Constants
    • Icon API
    • Link handling
      • Link handler configuration
      • LinkBrowser API
      • The LinkHandler API
        • The PageLinkHandler
        • The RecordLinkHandler
        • Implementing a custom LinkHandler
        • Events to modify link handler
      • Core link handler
      • Frontend link builder
      • LinkBrowser Tutorials
        • Browse records of a table
        • Create a custom link browser
    • Localization
      • Introduction
      • Supported languages
      • Managing translations
      • Translation servers
        • Localization with Crowdin
          • Extension integration
          • Online translation with Crowdin
          • Workflow
          • Frequently asked questions (FAQ)
        • Custom translation servers
      • Localization API
        • LanguageService
        • LanguageServiceFactory
        • Locale
        • LocalizationUtility (Extbase)
      • XLIFF Format
      • Working with XLIFF files
    • Locking API
    • Logging
      • Quickstart
      • Logger
      • Configuration of the logging system
      • The LogRecord model
      • Log writers
      • Log processors
    • Mail API
    • Message bus
    • Mount points
    • Namespaces
    • Page types
      • Types of pages
      • Redirect Headers
      • Create new Page Type
    • Pagination
    • Parsing HTML
    • Password hashing
      • Troubleshooting
    • Password policies
    • Requests
      • Bootstrapping
      • Middlewares (Request handling)
      • TYPO3 request object
      • TYPO3 request attributes
        • Application type
        • Current content object
        • Frontend controller
        • Frontend TypoScript
        • Frontend user
        • Language
        • Module
        • ModuleData
        • Nonce
        • Normalized parameters
        • Route
        • Routing
        • Site
        • Target
    • Routing
      • Introduction
      • Page based
      • For extensions
      • Extending
      • Examples
    • RTE
      • CKEditor Rich Text Editor
      • Rendering in the Frontend
      • Rich text editors in the TYPO3 backend
        • Introduction
        • Plugging in a custom RTE
      • Rich Text Editors (RTE) in the TYPO3 frontend
        • Including a Rich Text Editor (RTE) in the frontend
      • RTE Transformations
        • Introduction
        • Transformation overview
      • Historical Perspective on RTE Transformations
        • Properties and Transformations
        • RTE Transformations in Content Elements
    • SEO
      • Canonical API
      • MetaTag API
      • Page title API
      • XML sitemap
    • Services
      • Introduction
      • Using Services
        • Service precedence
        • Simple usage
        • Use with subtypes
        • Calling a chain of services
      • Configuration
        • Override service registration
        • Service configuration
        • Service type configuration
      • Developer's Guide
        • Introducing a new service type
        • Implementing a service
        • Service API
        • Services API
    • Sessions
      • User session management
      • Session storage framework
    • Site handling
      • Basics
      • Creation
      • Base variants
      • Adding Languages
      • Error handling
        • Page-based error handler
        • Fluid-based error handler
        • Writing a custom page error handler
      • Static routes
      • Environment variables
      • Usage in TypoScript + Fluid
      • Usage
      • Usage in TCA
      • Site settings
      • Console tools
      • PHP API
      • Extended configuration
    • Soft references
    • Symfony expression language
    • System Overview
    • System registry
    • TSFE
    • TYPO3 information
    • Webhooks and reactions
    • Versioning and Workspaces
    • XCLASSes
  • Administration
    • Installation
      • Classic mode installation
        • TYPO3 release integrity
      • Composer-based Installation
      • Server installations
        • Composer on the server
      • System Requirements
    • Deployment
      • Configuring environments
      • Tools
        • Rsync
        • Deployer
      • CI/CD Automation
    • Directory structure
      • Classic mode installation
      • Flag files
    • Version Control (Git)
    • Upgrades
      • Patch/Bugfix update
      • Major upgrade
        • Pre-upgrade tasks
        • Upgrade the Core
        • Post-upgrade tasks
      • Upgrading extensions
      • Third-party tools
      • Classic mode upgrade
      • Applying Core patches
      • Migrate a TYPO3 project to Composer
        • Requirements
        • Migration steps
        • Migrating public web assets
        • Version control
      • Migrate content
    • System Settings
      • Maintenance Mode
      • Production Settings
    • Backend users
      • Adding Backend Users
      • Changing the backend language
      • Backend Privileges
      • Backend Users
      • Groups
      • Setting up User Permissions
      • Page Permissions
      • Setting up a User
    • Tuning
    • Troubleshooting
      • TYPO3
      • System Modules
      • PHP
      • Web Server
      • Database
    • Extension management
      • Installing Extensions - Classic mode
    • Permissions
      • General recommendations
      • Setting up backend user groups
  • Configuration
    • Overview
    • Glossary
    • Configuration module
    • $GLOBALS
    • System configuration
      • BE - backend configuration
      • DB - Database connections
      • EXT - Extension manager configuration
      • FE - frontend configuration
      • GFX - graphics configuration
      • HTTP - tune requests
      • LOG - Logging configuration
      • MAIL settings
      • SYS - System configuration
    • TypoScript
      • Introduction
      • Syntax
      • Frontend TypoScript
      • TSconfig
      • PHP API
      • Myths and FAQ
    • User settings configuration
      • ['columns'] Section
      • ['showitem'] section
      • Extending the user settings
      • View the configuration
    • YAML
      • YAML API
      • YAML syntax
      • Services.yaml
  • Coding guidelines
    • Introduction
    • PHP architecture
      • Services
      • Static Methods, static Classes, Utility Classes
      • Traits
      • Working with exceptions
    • PHP
      • General requirements for PHP files
      • File structure
      • PHP syntax formatting
      • Using phpDoc
    • PHP Best Practice
      • Named arguments
      • Singletons
      • Handling deprecations
      • Namespaces and class names of user files
    • JavaScript
    • TypeScript
    • TypoScript
    • TSconfig
    • XLIFF
    • YAML
    • reStructuredText
  • Extension development
    • Concepts
      • Introduction
      • System, third-party and custom extensions
      • Further reading
    • File structure
      • composer.json
      • ext_conf_template.txt
      • ext_emconf.php
      • ext_localconf.php
      • ext_tables.php
      • ext_tables.sql
      • ext_tables_static+adt.sql
      • ext_typoscript_constants.typoscript
      • ext_typoscript_setup.typoscript
      • Classes
      • Configuration
        • Backend
        • Extbase
          • Persistence
        • TCA
        • TsConfig
        • TypoScript
        • ContentSecurityPolicies.php
        • Icons.php
        • page.tsconfig
        • RequestMiddlewares.php
        • Services.yaml
        • user.tsconfig
      • Documentation
      • Resources
        • Private
          • Language
        • Public
      • Tests
    • Site package
      • Introduction
    • Howto
      • Backend modules
        • Modules.php
        • Plain controller
        • Extbase controller
        • Security Considerations
        • Tutorials
      • Events
      • Extending an Extbase model
      • Extending the TCA array
        • Storing the changes
        • Customization Examples
        • Verifying the TCA
      • Frontend plugin
      • Localization
        • Multi-language Fluid templates
        • Localization in PHP
        • TypoScript
      • Publish your extension
        • Publish your extension in the TER
      • HTTP requests to external sources
      • Update your extension for new TYPO3 versions
        • Extension scanner
        • Upgrade wizards
          • The concept of upgrade wizards
          • Creating upgrade wizards
      • Configuration
      • Creating a new distribution
      • Creating a new extension
      • Custom Extension Repository
      • Adding documentation
    • Extbase
      • Introduction
      • Reference
        • Domain
          • Extbase model - extending AbstractEntity
            • Persistence
            • Relations
            • Hydrating
            • Localization
          • Repository
        • Controller
          • ActionController
          • Error action
          • Property mapping
          • Type converters
        • View
        • URI builder (Extbase)
        • Registration of frontend plugins
        • TypoScript configuration
        • Annotations
        • Validation
          • Custom Validator
        • File upload
        • Caching
        • Localization
        • URI arguments and reserved keywords
      • Examples
    • Best practises and conventions
      • Choosing an extension key
      • Naming conventions
      • Configuration Files (ext_tables.php & ext_localconf.php)
      • Software Design Principles
      • Extension loading order
    • Tutorials
      • Kickstart
        • Make
          • Create a new backend controller
          • Create a new console command
      • Tea
        • Create an extension
        • Create a directory structure
        • Model: a bag of tea
        • Repository
        • Controller
      • Components of a TYPO3 extension
        • Making the extension installable
        • Creating a new database model
        • Making data persistable by Extbase
      • Extbase
  • Security guidelines
    • Introduction
    • The TYPO3 Security Team
    • General Information
    • Types of Security Threats
    • General guidelines
    • Guidelines for System Administrators
      • Role Definition
      • Integrity of TYPO3 Packages
      • File/directory permissions
      • Restrict access to files on a server-level
      • Disable directory indexing
      • File extension handling
      • Content security policy
      • Database access
      • Encrypted Client/server Communication
      • Other Services
      • Further Actions
    • Guidelines for extension development
    • Guidelines for TYPO3 integrators
      • Install tool
      • Global TYPO3 configuration options
      • Security-related warnings after login
      • Reports and logs
      • Users and access privileges
      • TYPO3 extensions
      • TypoScript
      • Content elements
    • Guidelines for editors
    • Backup strategy
    • Detect, analyze and repair a hacked site
      • Detect a hacked website
      • Take the website offline
      • Analyzing a hacked site
      • Repair/restore
      • Further actions
  • Testing
    • Extension testing
    • Project testing
    • Unit tests
      • Introduction
      • Running
    • Functional tests
      • Introduction
    • Acceptance tests
    • Test Runners: Organize and execute tests
    • Testing tutorials
      • Testing enetcache
      • Acceptance testing of site_introduction
  • About This Manual
  • Sitemap
  1. TYPO3 Explained
  2. API A-Z
  3. Backend APIs
  4. UriBuilder
Give feedback Edit on GitHub

Use the backend UriBuilder to link to "Edit Records"

It is often needed to create links to edit records in the TYPO3 backend. The same syntax is also used for creating new records. TYPO3 provides an API for creating such links, namely \TYPO3\CMS\Backend\Routing\UriBuilder.

Hint

Make sure to use \TYPO3\CMS\Backend\Routing\UriBuilder to create backend links and not \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder.

The variable available as $this->uriBuilder in a controller is the web routing UriBuilder and can only be used for frontend links.

When using Fluid templates the URI either has to be created via PHP in the controller or a ViewHelper to be used.

Display a link to "Edit Record"

The Uri.editRecord ViewHelper <be:uri.editRecord> can be used to create a "create new record" link:

EXT:my_extension/Resources/Private/Partials/BackendModule/EditRecordLink.html
{namespace be=TYPO3\CMS\Backend\ViewHelpers\}
{namespace core=TYPO3\CMS\Core\ViewHelpers\}
<a href="{be:uri.editRecord(uid:2, table:'pages', returnUrl:'foo/bar')}">
    <core:icon identifier="actions-document-open"/>
    Edit Page 2
</a>
Copied!

If you create the backend link via PHP it is possible to add more options like default values for certain fields.

EXT:my_extension/Classes/Controller.php
<?php

namespace MyVendor\MyExtension\Controller;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UriInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class ModuleController extends ActionController
{
    public function __construct(
        protected readonly ModuleTemplateFactory $moduleTemplateFactory,
        private readonly UriBuilder $backendUriBuilder,
    ) {}

    protected function getEditLink(): UriInterface
    {
        $uriParameters = [
            'edit' =>
                [
                    'pages' => [1 => 'edit'],
                ],
        ];
        return $this->backendUriBuilder
            ->buildUriFromRoute('record_edit', $uriParameters);
    }

    public function linksAction(): ResponseInterface
    {
        $backendView = $this->initializeModuleTemplate($this->request);
        $editPage1Link = $this->getEditLink();
        $backendView->assignMultiple(
            [
                'editPage1Link' => $editPage1Link,
            ],
        );
        return $backendView->renderResponse('ShowPost');
    }
    protected function initializeModuleTemplate(
        ServerRequestInterface $request,
    ): ModuleTemplate {
        $view = $this->moduleTemplateFactory->create($request);

        // ...

        return $view;
    }
}
Copied!

Examples of "Edit record" links

Extension examples, file Resources/Private/Templates/Module/Links.html
<html data-namespace-typo3-fluid="true"
			xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
			xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
			xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
>

<h1>
	<f:translate key="function_links"/>
</h1>

<p>
	<f:translate key="function_links_intro"/>
</p>
<p>
	<a href="{editPage1Link}">
		<core:icon identifier="actions-document-open"/>
		<f:translate key="function_links_edit_page"/> 1
	</a>
</p>
<p>
	<f:comment>Would only output the uri: <be:uri.editRecord uid="2" table="pages" returnUrl="foo/bar" /></f:comment>
	<a href="{be:uri.editRecord(uid:2, table:'pages', returnUrl:'foo/bar')}">
		<core:icon identifier="actions-document-open"/>
		<f:translate key="function_links_edit_page"/> 2
	</a>
</p>
<p>
	<a href="{editPagesDoktypeLink}">
		<core:icon identifier="actions-document-open"/>
		<f:translate key="function_links_edit_pages_doktype"/>
	</a>
</p>
<p>
	<f:comment>Would only output the uri: <be:uri.newRecord pid="1" table="tx_examples_haiku" returnUrl="foo/bar" /></f:comment>
	<a href="{be:uri.newRecord(pid:1, table:'tx_examples_haiku', returnUrl:'foo/bar')}">
		<core:icon identifier="actions-document-new"/>
		<f:translate key="function_links_new_haiku"/>
	</a>
</p>
<p>
	<a href="{createHaikuLink}">
		<core:icon identifier="actions-document-new"/>
		<f:translate key="function_links_new_spring_haiku"/>
	</a>
</p>
</html>
Copied!

The links appear as one can expect:

The two links in the Examples module

For the first link the variable editPage1Link has to be set in the controller for example like this:

Extension examples, file Classes/Controller/ModuleController.php
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;

class ModuleController extends ActionController implements LoggerAwareInterface
{
    public function linksAction(): ResponseInterface
    {
        $backendUriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
        $uriParameters = ['edit' => ['pages' => [1 => 'edit']]];
        $editPage1Link = $backendUriBuilder->buildUriFromRoute('record_edit', $uriParameters);

        $uriParameters =
            [
                'edit' =>
                    [
                        'pages' =>
                            [
                                1 => 'edit',
                                2 => 'edit'
                            ],
                        'tx_examples_haiku' =>
                            [
                                1 => 'edit'
                            ]
                    ],
                'columnsOnly' => 'title,doktype'
            ];
        $editPagesDoktypeLink = $backendUriBuilder->buildUriFromRoute('record_edit', $uriParameters);
        $uriParameters =
            [
                'edit' =>
                    [
                        'tx_examples_haiku' =>
                            [
                                1 => 'new'
                            ]
                    ],
                'defVals' =>
                    [
                        'tx_examples_haiku' =>
                            [
                                'title' => 'New Haiku?',
                                'season' => 'Spring'
                            ]
                    ],
                'columnsOnly' => 'title,season,color'
            ];
        $createHaikuLink = $backendUriBuilder->buildUriFromRoute('record_edit', $uriParameters);
        $this->view->assignMultiple(
            [
                'editPage1Link' => $editPage1Link,
                'editPagesDoktypeLink' => $editPagesDoktypeLink,
                'createHaikuLink' => $createHaikuLink,
            ]
        );
        return $this->htmlResponse();
    }
}
Copied!

Editing a Record

The examples above leads to the normal edit form for a page:

Page 1 ready for editing with the standard form

Additional options for editing records

When creating the link via PHP it is possible to add more options.

You can specify as many tables and UIDs as needed and you will get them all in one single form! (short way of editing more records from the same table at once).

Also the fields to be displayed can be restricted.

EXT:my_extension/Classes/Controller.php
<?php

namespace MyVendor\MyExtension\Controller;

use Psr\Http\Message\UriInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;

class ModuleController
{
    public function __construct(
        private readonly UriBuilder $backendUriBuilder,
    ) {}

    private function getEditLink(): UriInterface
    {
        $uriParameters =
            [
                'edit' =>
                    [
                        'pages' =>
                            [
                                1 => 'edit',
                                2 => 'edit',
                            ],
                        'tx_examples_haiku' =>
                            [
                                1 => 'edit',
                            ],
                    ],
                'columnsOnly' => 'title,doktype',
            ];
        return $this->backendUriBuilder
            ->buildUriFromRoute('record_edit', $uriParameters);
    }
}
Copied!

The fields to be included can be listed in the columnsOnly parameter, as a comma-separated list. The order of the fields doesn't matter, they get displayed in the order they appear in the TCA. If a field is missing or access restricted in one of the tables it just doesn't appear. However if one record to be edited is missing none of the records gets displayed.

The example above results in the following:

Editing of fields of two pages and one haiku at once

Display a link to "Create a New Record"

The Uri.newRecord ViewHelper <be:uri.newRecord> can be used to create a "create new record" link:

EXT:my_extension/Resources/Private/Partials/BackendModule/CreateLink.html
{namespace be=TYPO3\CMS\Backend\ViewHelpers\}
{namespace core=TYPO3\CMS\Core\ViewHelpers\}
<a href="{be:uri.newRecord(pid:1, table:'tx_examples_haiku', returnUrl:'foo/bar')}">
    <core:icon identifier="actions-document-new"/>
    Create a new Haiku
</a>
Copied!

If you create the backend link via PHP it is possible to add more options like default values for certain fields.

EXT:my_extension/Classes/Controller.php
<?php

namespace MyVendor\MyExtension\Controller;

use Psr\Http\Message\UriInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;

class ModuleController
{
    public function __construct(
        private readonly UriBuilder $backendUriBuilder,
    ) {}

    private function getCreateLink(): UriInterface
    {
        $uriParameters =
            [
                'edit' =>
                    [
                        'tx_examples_haiku' =>
                            [
                                1 => 'new',
                            ],
                    ],
                'defVals' =>
                    [
                        'tx_examples_haiku' =>
                            [
                                'title' => 'New Haiku?',
                                'season' => 'Spring',
                            ],
                    ],

                'columnsOnly' => 'title,season,color',
            ];
        return $this->backendUriBuilder
            ->buildUriFromRoute('record_edit', $uriParameters);
    }
}
Copied!

The link triggers the creation a new record for the table tx_examples_haiku on page 1. It also sets a default value for the title field ("New haiku") and selects the season "Spring". It only displays the fields defined by columnsOnly.

Note the following things:

  • the first parameter is called "edit" even if this is about creating a new record. The creation of a record is indicated by the value "new".
  • the key of the entry with value "new" indicates the pid on which the record is to be created.
  • the values get automatically url-encoded so you can use any special char in the defaults

This results in the following new record form with a pre-filled title and season field.

Form for creating a new haiku with pre-filled title and season and restricted columns

  • Previous
  • Next
Reference to the headline

Copy and freely share the link

This link target has no permanent anchor assigned. You can make a pull request on GitHub to suggest an anchor. The link below can be used, but is prone to change if the page gets moved.

Copy this link into your TYPO3 manual.

  • Home
  • Contact
  • Issues
  • Repository

Last rendered: May 14, 2025 06:14

© since 2012 by the TYPO3 contributors
  • Legal Notice
  • Privacy Policy