TYPO3 Logo
TYPO3 Explained
Release: 10.4

Loading data.

  • Introduction
  • API A-Z
    • Backend Access Control (Users & Roles)
      • Users and Groups
      • Password Reset Functionality
      • Roles
      • Access Control Options
      • Other Options
      • More About File Mounts
      • Backend Users Module
    • AJAX
      • Client-Side Programming
      • Backend
    • Assets (CSS, JavaScript, Media)
    • Authentication
    • Autoloading
    • Backend Layout
    • Backend Modules
      • Backend Interface
      • The Backend Template View
      • Backend Module API
    • Backend Routing
    • Backend User Object
    • Bootstrapping
    • Broadcast Channels
    • Caching
      • Quick Start for Integrators
      • Configuration
      • Caching Framework Architecture
      • Cache frontends
      • Cache backends
      • Developer Information
    • System Categories
    • System Collections
    • Symfony Console Commands (cli)
    • Content Elements & Plugins
      • Introduction
      • Create Custom Content Elements
      • Create Plugins
      • Configure Custom Backend Preview for Content Element
      • Add Elements to the Content Element Wizard
      • Flexforms
      • Backend Layout
      • Best practices
    • Context API and Aspects
    • Context Sensitive Help (CSH)
      • The $TCA_DESCR Array
      • The Language Files for CSH
      • Implementing CSH
    • Crop Variants for Images
      • General Configuration
      • Crop variants configuration per content element
    • Data Formats
    • Database (doctrine-dbal)
      • Introduction
      • Configuration
      • Database Structure
      • Upgrade Table and Field Definitions
      • Basic CRUD
      • Class Overview
      • ConnectionPool
      • QueryBuilder
      • Connection
      • ExpressionBuilder
      • RestrictionBuilder
      • Statement
      • QueryHelper
      • Migrating from TYPO3_DB
      • Various Tips and Tricks
    • Debugging
    • Dependency Injection
    • Deprecation
    • Directory Structure
    • Enumerations & BitSets
      • How To Use Enumerations
      • How To Use BitSets
    • Environment
    • Error and Exception Handling
      • Configuration
      • Error Handler
      • Production Exception Handler
      • Debug Exception Handler
      • Examples
      • How to extend the error and exception handling
    • Events, Signals and Hooks
      • Extending the TYPO3 Core
      • EventDispatcher (PSR-14 Events)
      • Event list
        • Backend
          • AfterFormEnginePageInitializedEvent
          • AfterHistoryRollbackFinishedEvent
          • AfterPageColumnsSelectedForLocalizationEvent
          • BeforeFormEnginePageInitializedEvent
          • BeforeHistoryRollbackStartEvent
          • ModifyPageLayoutOnLoginProviderSelectionEvent
          • SwitchUserEvent
          • SystemInformationToolbarCollectorEvent
        • Core
          • Configuration
            • AfterTcaCompilationEvent
            • ModifyLoadedPageTsConfigEvent
          • DataHandling
            • AppendLinkHandlerElementsEvent
            • IsTableExcludedFromReferenceIndexEvent
          • Database
            • AlterTableDefinitionStatementsEvent
          • Html
            • BrokenLinkAnalysisEvent
          • Mail
            • AfterMailerInitializationEvent
          • Package
            • AfterPackageActivationEvent
            • AfterPackageDeactivationEvent
            • BeforePackageActivationEvent
            • PackagesMayHaveChangedEvent
          • Page
            • BeforeJavaScriptsRenderingEvent
            • BeforeStylesheetsRenderingEvent
          • Resource
            • AfterFileAddedEvent
            • AfterFileAddedToIndexEvent
            • AfterFileContentsSetEvent
            • AfterFileCopiedEvent
            • AfterFileCreatedEvent
            • AfterFileDeletedEvent
            • AfterFileMarkedAsMissingEvent
            • AfterFileMetaDataCreatedEvent
            • AfterFileMetaDataDeletedEvent
            • AfterFileMetaDataUpdatedEvent
            • AfterFileMovedEvent
            • AfterFileProcessingEvent
            • AfterFileRemovedFromIndexEvent
            • AfterFileRenamedEvent
            • AfterFileReplacedEvent
            • AfterFileUpdatedInIndexEvent
            • AfterFolderAddedEvent
            • AfterFolderCopiedEvent
            • AfterFolderDeletedEvent
            • AfterFolderMovedEvent
            • AfterFolderRenamedEvent
            • AfterResourceStorageInitializationEvent
            • BeforeFileAddedEvent
            • BeforeFileContentsSetEvent
            • BeforeFileCopiedEvent
            • BeforeFileCreatedEvent
            • BeforeFileDeletedEvent
            • BeforeFileMovedEvent
            • BeforeFileProcessingEvent
            • BeforeFileRenamedEvent
            • BeforeFileReplacedEvent
            • BeforeFolderAddedEvent
            • BeforeFolderCopiedEvent
            • BeforeFolderDeletedEvent
            • BeforeFolderMovedEvent
            • BeforeFolderRenamedEvent
            • BeforeResourceStorageInitializationEvent
            • EnrichFileMetaDataEvent
            • GeneratePublicUrlForResourceEvent
            • ModifyIconForResourcePropertiesEvent
            • SanitizeFileNameEvent
          • Tree
            • ModifyTreeDataEvent
        • Extbase
          • Mvc
            • AfterRequestDispatchedEvent
            • BeforeActionCallEvent
          • Persistence
            • AfterObjectThawedEvent
            • EntityAddedToPersistenceEvent
            • EntityPersistedEvent
            • EntityRemovedFromPersistenceEvent
            • EntityUpdatedInPersistenceEvent
            • ModifyQueryBeforeFetchingObjectDataEvent
            • ModifyResultAfterFetchingObjectDataEvent
        • ExtensionManager
          • AfterExtensionDatabaseContentHasBeenImportedEvent
          • AfterExtensionFilesHaveBeenImportedEvent
          • AfterExtensionStaticDatabaseContentHasBeenImportedEvent
          • AvailableActionsForExtensionEvent
        • Frontend
          • ModifyHrefLangTagsEvent
        • FrontendLogin
          • LoginConfirmedEvent
          • ModifyLoginFormViewEvent
          • SendRecoveryEmailEvent
        • Impexp
          • BeforeImportEvent
        • Install
          • ModifyLanguagePackRemoteBaseUrlEvent
        • Linkvalidator
          • BeforeRecordIsAnalyzedEvent
        • Seo
          • ModifyUrlForCanonicalTagEvent
        • Setup
          • AddJavaScriptModulesEvent
        • Workspaces
          • AfterCompiledCacheableDataForWorkspaceEvent
          • AfterDataGeneratedForWorkspaceEvent
          • GetVersionedDataEvent
          • SortVersionedDataEvent
      • Signals and Slots (deprecated)
      • Hooks
      • JavaScript Event API
        • Regular Event
        • Debounce Event
        • Throttle Event
        • RequestAnimationFrame Event
    • Examples
      • Rendering Page Trees
      • Clipboard
      • Context-Sensitive Menus
      • Parsing HTML
      • Links to Edit Records
      • Using Custom Permission Options
    • Extension Scanner
    • Digital Assets Management (FAL)
      • Introduction
      • 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 ResourceFactory Class
        • Working With Files, Folders and File References
        • Working With Collections
        • Searching for Files
    • Custom File Processors
    • Flash Messages
    • Flexforms
    • Fluid
      • Introduction to Fluid
    • FormEngine
      • Introduction
      • Main Rendering Workflow
      • Data Compiling
      • Rendering
    • Form Protection Tool
    • Variables and Constants
    • HTTP Request Library / Guzzle / PSR-7
    • Icon API
    • Internationalization and Localization
      • Introduction
      • Supported languages
      • Managing Translations
      • Translation Servers
        • Localization with Crowdin
          • Extension Integration
          • Online Translation with Crowdin
          • Workflow
          • Frequently Asked Questions (FAQ)
        • Localization with Pootle
        • Custom Translation Servers
      • XLIFF Format
      • Working with XLIFF files
    • JavaScript in TYPO3 Backend
      • RequireJS in the TYPO3 Backend
        • Use RequireJS in Your Own Extension
        • Dependency Handling
        • Loading Your Own or Other RequireJS Modules
        • Shim Library to Use it as Own RequireJS Modules
      • Various JavaScript Modules
        • Modals
        • Multi-Step Wizard
        • DocumentService (jQuery.ready substitute)
      • Event Api
      • Navigation via JavaScript
      • JavaScript Form Helpers
    • Linkbrowser
      • LinkBrowser API
      • LinkHandler Api
    • Locking API
    • Logging Framework
      • Quickstart
      • Logger
      • Configuration of the Logging System
      • The LogRecord Model
      • Log Writers
      • Log Processors
    • Mail API
    • MetaTag API
    • Namespaces
    • PageTitle API
    • Page Types
    • Pagination
    • Password Hashing
    • Request Handling (Middlewares)
      • TYPO3 Request Object
    • Routing - "Speaking URLs" in TYPO3
      • Introduction to Routing
      • Page based Routing
      • Advanced Routing Configuration (for Extensions)
      • Extending Routing
      • Collection of various routing examples
    • Rich Text Editors (RTE)
      • CKEditor Rich Text Editor
      • Rich Text Editors in the TYPO3 Backend
        • Introduction
        • Plugging a RTE
      • RTE Transformations
        • Introduction
        • Transformation Overview
        • Custom Transformations API
      • Historical Perspective on RTE Transformations
        • Properties and Transformations
        • RTE Transformations in Content Elements
    • SEO
      • MetaTag API
      • PageTitle API
      • XML Sitemap
    • Services
      • Introduction
      • Using Services
        • Service Precedence
        • Simple Use
        • Use With Subtypes
        • Calling a Chain of Services
      • Configuration
        • Registration Changes
        • Service Configuration
        • Service Type Configuration
      • Developer's Guide
        • Introducing a New Service Type
        • Implementing a Service
        • Service API
        • Service-related API
    • Session Storage Framework
    • Site Handling
      • Basics
      • Creating a new site configuration
      • Base Variants
      • Adding Languages
      • Error Handling
      • Writing a Custom Page Error Handler
      • Static Routes
      • Using Environment Variables in Site Configuration
      • Using Site Configuration in TypoScript
      • Using Site Config in Conditions
      • Site Settings
      • CLI Tools for Site Handling
      • PHP API: Accessing Site Configuration
      • Extending Site Configuration
    • Soft References
    • Symfony Expression Language
    • System Log
    • System Registry
    • TSFE
    • TCE (TYPO3 Core Engine) & DataHandler
      • Introduction
      • Database: DataHandler Basics (Formerly Known as TCEmain)
      • Using DataHandler in Scripts
      • The "/record/commit" Route
      • File Functions Basics
      • The "tce_file.php" API
    • Upgrade Wizards
      • The Concept of Upgrade Wizards
      • Creating upgrade wizards
      • class.ext_update.php
    • Versioning and Workspaces
    • XCLASSes (Extending Classes)
    • XML Sitemap
  • Coding Guidelines
    • Introduction
    • PHP Coding Guidelines
      • PHP File Formatting
        • General Requirements for PHP Files
        • File Structure
        • PHP Syntax Formatting
        • Using phpDoc
      • PHP Architecture
        • Modeling Cross Cutting Concerns
          • Static Methods, static Classes, Utility Classes
          • Traits
          • Services
        • Working With Exceptions
        • General Links
      • Coding: Best practices
        • Accessing the Database
        • Singletons
        • Static Methods
        • Localization
        • Unit Tests
        • Handling Deprecation
        • Namespaces and Class Names of User Files
        • Hook Naming
    • JavaScript Coding Guidelines
    • TypeScript Coding Guidelines
    • TypoScript Coding Guidelines
    • TSconfig Coding Guidelines
    • Xliff Coding Guidelines
    • Yaml Coding Guidelines
    • reStructuredText (reST)
  • Configuration
    • Configuration overview
    • Glossary
    • Feature Toggles
    • $GLOBALS
    • $GLOBALS['TYPO3_CONF_VARS']
    • Global Meta Information about TYPO3
    • TSconfig
    • TypoScript Syntax
      • What Is TypoScript?
      • Syntax
        • Introduction
        • Contexts
        • TypoScript syntax
        • Conditions
        • Includes
      • Sorting out Details
        • Parsing, Storing and Executing TypoScript
        • Myths, FAQ and Acknowledgements
      • The TypoScript Parser API
        • Introduction
        • Parsing Custom TypoScript
        • Implementing Custom Conditions
    • User Settings Configuration
      • ['columns'] Section
      • ['showitem'] Section
      • Extending the User Settings
      • View the Configuration
    • YAML
      • YAML API
      • YAML syntax
      • Services.yaml
  • Extension development
    • Introduction
    • Extension Management
    • System and Local Extensions
    • Files and Locations
    • composer.json
    • Declaration File (ext_emconf.php)
    • Configuration Files (ext_tables.php & ext_localconf.php)
    • Naming Conventions
    • Extension Configuration (ext_conf_template.txt)
    • Extending the TCA Array
      • Storing the Changes
      • Customization Examples
      • Verifying the TCA
    • Choosing an extension key
    • Creating a new Extension
    • Creating a new distribution
    • Adding Documentation
    • Extbase
    • Frontend plugin
      • AbstractPlugin
    • Publish Your Extension
      • Publish your extension in the TER
    • Other resources
  • Security Guidelines
    • Introduction
    • The TYPO3 Security Team
    • General Information
    • Types of Security Threats
    • General Guidelines
    • Guidelines for System Administrators
    • Guidelines for TYPO3 Integrators
    • Guidelines for Editors
    • Backup Strategy
    • Detect, Analyze and Repair a Hacked Site
  • Testing
    • History
    • Core testing
    • Extension testing
    • Project testing
    • Writing unit tests
    • Writing functional tests
    • Writing acceptance tests
    • FAQ
  • About This Manual
  • Sitemap
  • Index

PAGE CONTENTS

  • Links to Edit Records
    • Editing a Record
    • Additional options for editing redords
    • Display a Link to Create a New Record
  1. Start
  2. API A-Z
  3. Examples
  4. Links to Edit Records
View source How to edit Edit on GitHub

Display settings


Color scheme of code blocks:


Links 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, you cannot call PHP code directly. Therefore the uri either has to be created via PHP in the controller or a viewhelper to be used.

Below are a different examples, how edit links can be output in the backend.

<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"
                     xmlns:ex="http://typo3.org/ns/T3docs/Examples/ViewHelpers"
>
   <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:1, table:'pages', returnUrl:'foo/bar')}">
         <core:icon identifier="actions-document-open"/>
         <f:translate key="function_links_edit_page_2"/>
      </a>
   </p>
</html>

The links appear as one can expect:

Edit links in the examples BE module

The two links in the "examples" BE module¶

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

public function linksAction()
{
    $backendUriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
    $uriParameters = ['edit' => ['pages' => [1 => 'edit']]];
    $editPage1Link = $backendUriBuilder->buildUriFromRoute('record_edit', $uriParameters);
    $this->view->assignMultiple(
        [
            'editPage1Link' => $editPage1Link,
        ]
    );
}

Editing a Record¶

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

The standard form for editing a page

Page 1 ready for editing with the standard form¶

Additional options for editing redords¶

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

You can specify as many tables and uids you like 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.

$uriParameters =
   [
      'edit' =>
         [
            'pages' =>
               [
                  1 => 'edit',
                  2 => 'edit'
               ],
            'tx_examples_haiku' =>
               [
                  1 => 'edit'
               ]
         ],
      'columnsOnly' => 'title,doktype'
   ];
$editPagesDoktypeLink = $backendUriBuilder->buildUriFromRoute('record_edit', $uriParameters);

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:

The restricted form for editing a page

Editing of fields of two pages and one haiku at once¶

Display a Link to Create a New Record¶

There is a backend viewhelper to display a "create new record" link:

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

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

$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);

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 still 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.

Creating a new haiku

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

  • Previous
  • Next
  • Home
  • Contact
  • Issues
  • Repository

Last updated: Mar 24, 2023 18:24

Last rendered: Mar 24, 2023 18:24

  • TYPO3 Theme 4.7.9
  • DRC v3.0.dev30
© Copyright since 2012 by the TYPO3 contributors
  • Legal Notice
  • Privacy Policy
  • Code of Conduct