TYPO3 Logo
TYPO3 Explained
Release: master

Loading data.

  • Quick Links
    • Configuration Overview
    • Database (doctrine-dbal)
    • Dependency Injection
    • Digital Assets Management
    • Fluid
    • Internationalization and Localization
    • Mail API
    • Request Handling (Middlewares)
    • Routing - "Speaking URLs"
    • Security Guidelines
    • Site Handling
  • Index
  • Introduction
  • 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
    • Publish your extension
    • Other resources
    • Custom Extension Repository

TYPO3 A-Z

  • Ajax
    • Client-side programming
    • Backend
  • Assets (CSS, JavaScript, Media)
  • Authentication
    • Multi-Factor Authentication
  • Autoloading
  • Backend access control (Users & Roles)
    • Users and groups
    • Password reset functionality
    • Roles
    • Access Control Options
    • Other Options
    • More about file mounts
    • Backend users module
  • 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
  • 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
    • Configuration module
    • 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 API
    • YAML syntax
  • Constants
  • Content Elements & Plugins
    • Introduction
    • Creating a custom content element
    • Custom data processors
    • Create plugins
    • Configure Custom Backend Preview for Content Element
    • Add content elements to the Content Element Wizard
    • Flexforms
    • T3DataStructure
      • Elements
      • Sheet References
      • Parsing a Data Structure
    • 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
  • Custom file processors
  • Database (Doctrine DBAL)
    • Introduction
    • Configuration
    • Database Structure
    • Upgrade table and field definitions
    • Basic create, read, update, and delete operations (CRUD)
    • Class Overview
    • ConnectionPool
    • QueryBuilder
    • Connection
    • ExpressionBuilder
    • RestrictionBuilder
    • Statement
    • QueryHelper
    • Migrating from TYPO3_DB
    • Various Tips and Tricks
  • Debugging
  • Dependency injection
  • Deprecation
  • File abstraction layer (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 StorageRepository Class
      • Working With files, folders and file references
      • Working With Collections
      • Searching for Files
    • File collections
  • 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)
    • List of Core PSR-14 Events
      • AfterFormEnginePageInitializedEvent
      • AfterHistoryRollbackFinishedEvent
      • AfterPageColumnsSelectedForLocalizationEvent
      • BeforeFormEnginePageInitializedEvent
      • BeforeHistoryRollbackStartEvent
      • ModifyPageLayoutOnLoginProviderSelectionEvent
      • SwitchUserEvent
      • SystemInformationToolbarCollectorEvent
      • AfterGroupsResolvedEvent
      • AfterTcaCompilationEvent
      • ModifyLoadedPageTsConfigEvent
      • AlterTableDefinitionStatementsEvent
      • AppendLinkHandlerElementsEvent
      • IsTableExcludedFromReferenceIndexEvent
      • BrokenLinkAnalysisEvent
      • AfterMailerInitializationEvent
      • AfterPackageActivationEvent
      • AfterPackageDeactivationEvent
      • BeforePackageActivationEvent
      • PackagesMayHaveChangedEvent
      • BeforeJavaScriptsRenderingEvent
      • BeforeStylesheetsRenderingEvent
      • AfterFileAddedEvent
      • AfterFileAddedToIndexEvent
      • AfterFileContentsSetEvent
      • AfterFileCopiedEvent
      • AfterFileCreatedEvent
      • AfterFileDeletedEvent
      • AfterFileMarkedAsMissingEvent
      • AfterFileMetaDataCreatedEvent
      • AfterFileMetaDataDeletedEvent
      • 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
      • ModifyTreeDataEvent
      • AfterRequestDispatchedEvent
      • BeforeActionCallEvent
      • AfterObjectThawedEvent
      • EntityAddedToPersistenceEvent
      • EntityPersistedEvent
      • EntityRemovedFromPersistenceEvent
      • EntityUpdatedInPersistenceEvent
      • ModifyQueryBeforeFetchingObjectDataEvent
      • ModifyResultAfterFetchingObjectDataEvent
      • AfterExtensionDatabaseContentHasBeenImportedEvent
      • AfterExtensionFilesHaveBeenImportedEvent
      • AfterExtensionStaticDatabaseContentHasBeenImportedEvent
      • AvailableActionsForExtensionEvent
      • ModifyHrefLangTagsEvent
      • LoginConfirmedEvent
      • ModifyLoginFormViewEvent
      • SendRecoveryEmailEvent
      • BeforeImportEvent
      • ModifyLanguagePackRemoteBaseUrlEvent
      • BeforeRecordIsAnalyzedEvent
      • RenderAdditionalContentToRecordListEvent
      • ModifyUrlForCanonicalTagEvent
      • AddJavaScriptModulesEvent
      • AfterCompiledCacheableDataForWorkspaceEvent
      • AfterDataGeneratedForWorkspaceEvent
      • GetVersionedDataEvent
      • SortVersionedDataEvent
    • Signals and slots (deprecated)
    • Hooks
    • JavaScript Event API
      • Regular event
      • Debounce event
      • Throttle event
      • RequestAnimationFrame event
  • Extension scanner
  • Flash messages
  • Fluid
    • Introduction to Fluid
  • FormEngine
    • Introduction
    • Main rendering workflow
    • Data compiling
    • Rendering
  • Form protection tool
  • HTTP request library / Guzzle / PSR-7
  • Icon API
  • Internationalization and localization
    • Introduction
    • Supported languages
    • Managing translations for backend
    • 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
    • Client-side templating
    • Various JavaScript modules
      • Modals
      • Multi-step wizard
      • DocumentService (jQuery.ready substitute)
      • SessionStorage wrapper
    • Event Api
    • Navigation via JavaScript
    • JavaScript Form Helpers
  • LinkBrowser
    • LinkBrowser API
    • The LinkHandler API
      • The PageLinkHandler
      • The RecordLinkHandler
      • Implementing a custom LinkHandler
      • `<a href="t3://record?identifier=anIdentifier&amp;uid=456">A link</a>`.
  • Locking API
  • Logging Framework
    • Quickstart
    • Logger
    • Configuration of the logging system
    • The LogRecord model
    • Log Writers
    • Log processors
  • Mail API
  • Mount points
  • Namespaces
  • Page types
    • Introduction
    • Types of pages
    • X-Redirect-By header for pages with redirect types
    • Create new Page Type
  • Pagination
  • Password hashing
  • Request handling (Middlewares)
    • TYPO3 request object
  • Rich text editors (RTE)
    • CKEditor Rich Text Editor
    • Rich text editors in the TYPO3 backend
      • Introduction
      • Plugging in a custom RTE
    • RTE Transformations
      • Introduction
      • Transformation overview
    • Historical Perspective on RTE Transformations
      • Properties and Transformations
      • RTE Transformations in Content Elements
  • Routing - “Speaking URLs” in TYPO3
    • Introduction to Routing
    • Page based Routing
    • Advanced routing configuration (for extensions)
    • Extending Routing
    • Collection of various routing examples
  • 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
      • Directory indexing
      • File extension handling
      • Content security policy
      • Database access
      • Encrypted Client/server Communication
      • Other Services
      • Further Actions
    • 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
  • Search engine optimization (SEO)
    • MetaTag API
    • PageTitle 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
  • Session handling in TYPO3
    • User session management
    • Session storage framework
  • Site handling
    • Basics
    • Creating a new site
    • Base variants
    • Adding Languages
    • Error handling
    • Writing a custom page error handler
    • Static routes
    • Using environment variables in the site configuration
    • Using site configuration in TypoScript
    • Using site configuration in conditions
    • Site settings
    • CLI tools for site handling
    • PHP API: accessing site configuration
    • Extending site configuration
  • Soft references
  • Symfony Console Commands (cli)
  • Symfony expression language
  • System Categories
  • System registry
  • TCE (TYPO3 Core engine) & DataHandler
    • Introduction
    • Database: DataHandler basics (Formerly Known as TCEmain)
    • Using the DataHandler in scripts
    • The “/record/commit” Route
    • File Functions Basics
    • The “tce_file.php” API
  • Testing
    • History
    • Core testing
    • Extension testing
    • Project testing
    • Writing unit tests
    • Writing functional tests
    • Writing acceptance tests
    • FAQ
  • Upgrade wizards
    • The concept of upgrade wizards
    • Creating Generic Upgrade Wizards
  • Versioning and Workspaces
  • XCLASSes (Extending Classes)
  • Sitemap
  • About This Manual

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. Links to Edit Records
Edit on GitHub View source

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

  • Contact
  • Issues
  • Repository

Last updated: Feb 02, 2021 10:46

Last rendered: Feb 23, 2021 14:12

TYPO3 Theme 4.4.3

© Copyright since 2000 by the TYPO3 Documentation Team
  • Legal Notice
  • Privacy Policy