Feature: #97159 - New TCA type "link"¶
See forge#97159
Description¶
Especially TCA type input
has a wide range of use cases, depending
on the configured renderType
and the eval
options. Determination
of the semantic meaning is therefore usually quite hard and often leads to
duplicated checks and evaluations in custom extension code.
In our effort of introducing dedicated TCA types for all those use
cases, the TCA type link
has been introduced. It replaces the
renderType=inputLink
of TCA type input
.
The TCA type link
features the following column configuration:
allowedTypes
appearance
:enableBrowser
,browserTitle
,allowedOptions
,allowedFileExtensions
autocomplete
behaviour
:allowLanguageSynchronization
default
fieldControl
fieldInformation
fieldWizard
mode
nullable
placeholder
readOnly
required
search
size
valuePicker
Note
The soft reference definition softref=typolink
is automatically applied
to all TCA type link
columns.
Note
The value of TCA type link
columns is automatically trimmed before
being stored in the database. Therefore, the eval=trim
option is no
longer needed and should be removed from the TCA configuration.
The following column configurations can be overwritten by page TSconfig:
readOnly
size
The previously configured linkPopup
field control is now integrated
into the new TCA type directly. Additionally, instead of exclude lists
([blindLink[Fields|Options]
) the new type now use include lists.
Those lists are furthermore no longer comma-separated, but PHP arrays,
with each option as a separate value.
The replacement for the previously used blindLinkOptions
option is the
allowedTypes
configuration. The blindLinkFields
option is
now configured via appearance[allowedOptions]
. While latter only
affects the display in the Link Browser, the allowedTypes
configuration
is also evaluated in the DataHandler
, preventing the user from adding
links of non-allowed types.
To allow all link types, skip the allowedTypes
configuration or set
it to ['*']
. It's not possible to deny all types.
To allow all options in the Link Browser, skip the
appearance[allowedOptions]
configuration or set it to ['*']
. To
deny all options in the Link Browser, set the appearance[allowedOptions]
configuration to []
(empty array
).
The allowedExtensions
option is renamed to allowedFileExtensions
and also moved to appearance
. Now it requires to be an array
.
To allow all extensions, skip the appearance[allowedFileExtensions]
configuration or set it to ['*']
. It's not possible to deny all
extensions.
With appearance[browserTitle]
, a custom title for the Link Browser
can be defined. To disable the Link Browser, appearance[enableBrowser]
has to be set to false
.
A complete migration from renderType=inputLink
to type=link
looks like the following:
// Before
'a_link_field' => [
'label' => 'Link',
'config' => [
'type' => 'input',
'renderType' => 'inputLink',
'required' => true,
'nullable' => true,
'size' => 20,
'max' => 1024,
'eval' => 'trim',
'fieldControl' => [
'linkPopup' => [
'disabled' => true,
'options' => [
'title' => 'Browser title',
'allowedExtensions' => 'jpg,png',
'blindLinkFields' => 'class,target,title',
'blindLinkOptions' => 'mail,folder,file,telephone',
],
],
],
'softref' => 'typolink',
],
],
// After
'a_link_field' => [
'label' => 'Link',
'config' => [
'type' => 'link',
'required' => true,
'nullable' => true,
'size' => 20,
'allowedTypes' => ['page', 'url', 'record'],
'appearance' => [
'enableBrowser' => false,
'browserTitle' => 'Browser title',
'allowedFileExtensions' => ['jpg', 'png'],
'allowedOptions' => ['params', 'rel'],
],
]
]
An automatic TCA migration is performed on the fly, migrating all occurrences
to the new TCA type and triggering a PHP E_USER_DEPRECATED
error
where code adoption has to take place.
Note
The corresponding FormEngine class has been renamed from InputLinkElement
to LinkElement
. An entry in the "ClassAliasMap" has been added for
extensions calling this class directly, which is rather unlikely. The
extension scanner will report any usage, which should then be migrated.
Allowed type "record"¶
One of the primary tasks of the corresponding TCA migration is to migrate
the exclude lists to include lists. To achieve this, the migration would need
to know all possible values. Since the LinkHandler API provides the possibility
to use the RecordLinkHandler
as basis for various custom record types,
whose availability however depends on the page context, it's not possible for
the migration to add the custom record identifiers correctly. Therefore, the
record
type is added to the allowedTypes
, enabling all custom
record identifiers. The actually available identifiers are then resolved
automatically in the link
element, depending on the context.
To limit this in TCA already, replace the record
value with the
desired record identifiers.
// Before
'allowedTypes' => ['page', 'url', 'record'],
// After
'allowedTypes' => ['page', 'url', 'tx_news', 'tt_address'],
Impact¶
It's now possible to simplify the TCA configuration by using the new
dedicated TCA type link
.