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 render
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
render
of TCA type input
.
The TCA type link
features the following column configuration:
allowed
Types appearance
:enable
,Browser browser
,Title allowed
,Options allowed
File Extensions autocomplete
behaviour
:allow
Language Synchronization default
field
Control field
Information field
Wizard mode
nullable
placeholder
read
Only required
search
size
value
Picker
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:
read
Only size
The previously configured link
field control is now integrated
into the new TCA type directly. Additionally, instead of exclude lists
([blind
) 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 blind
option is the
allowed
configuration. The blind
option is
now configured via appearance
. While latter only
affects the display in the Link Browser, the allowed
configuration
is also evaluated in the Data
, preventing the user from adding
links of non-allowed types.
To allow all link types, skip the allowed
configuration or set
it to ['*']
. It's not possible to deny all types.
To allow all options in the Link Browser, skip the
appearance
configuration or set it to ['*']
. To
deny all options in the Link Browser, set the appearance
configuration to []
(empty array
).
The allowed
option is renamed to allowed
and also moved to appearance
. Now it requires to be an array
.
To allow all extensions, skip the appearance
configuration or set it to ['*']
. It's not possible to deny all
extensions.
With appearance
, a custom title for the Link Browser
can be defined. To disable the Link Browser, appearance
has to be set to false
.
A complete migration from render
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_
error
where code adoption has to take place.
Note
The corresponding FormEngine class has been renamed from Input
to Link
. 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 Record
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 allowed
, 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
.