Json

New in version 12.3

The TCA field type json has been added to TYPO3 Core.

When using the json type, TYPO3 takes care of generating the according database field. A developer does not need to define this field in an extension's ext_tables.sql file.

Example: Simple JSON field

The system extension typo3/cms-webhooks uses a TCA field of type JSON for the input of additional HTTP request header data:

The additional header field with some example input
EXT:webhooks/Configuration/TCA/sys_webhook.php
[
    'columns' => [
        'additional_headers' => [
            'label' => 'LLL:EXT:webhooks/Resources/Private/Language/locallang_db.xlf:sys_webhook.additional_headers',
            'description' => 'LLL:EXT:webhooks/Resources/Private/Language/locallang_db.xlf:sys_webhook.additional_headers.description',
            'config' => [
                'type' => 'json',
            ],
        ],
    ],
]
Copied!

Properties of the TCA column type json

Name Type Scope
boolean Proc.
integer Display
string
boolean
string
string
string
string Display
boolean Display
boolean Display / Proc.
integer Display

behaviour

behaviour

allowLanguageSynchronization

allowLanguageSynchronization
Type
boolean
Default
false
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['behaviour']['allowLanguageSynchronization']
Scope
Proc.

Allows an editor to select in a localized record whether the value is copied over from default or source language record, or if the field has an own value in the localization. If set to true and if the table supports localization and if a localized record is edited, this setting enables FieldWizard LocalizationStateSelector: Two or three radio buttons shown below the field input. The state of this is stored in a json encoded array in the database table called l10n_state. It tells the DataHandler which fields of the localization records should be kept in sync if the underlying default or source record changes.

EXT:my_extension/Configuration/TCA/Overrides/someTable.php
<?php

$jsonField = [
    'config' => [
        'type' => 'json',
        'behaviour' => [
            'allowLanguageSynchronization' => true,
        ],
    ],
];
Copied!

cols

cols
Type
integer
Default
30
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display

Abstract value for the width of the <textarea> field in which the JSON is displayed. To set the textarea to the full width of the form area, use the value 50.

This value can be overridden by page TSconfig.

default

default
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['default']

Default value set if a new record is created.

enableCodeEditor

enableCodeEditor
Type
boolean
Default
true
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['enableCodeEditor']

In case enableCodeEditor is set to true, which is the default and the system extension typo3/cms-t3editor is installed and active, the JSON value is rendered in the corresponding code editor.

Otherwise it is rendered in a standard textarea HTML element.

fieldControl

fieldControl
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']

See fieldControl for details.

fieldInformation

fieldInformation
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldInformation']

See fieldInformation for details.

fieldWizard

fieldWizard
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']

See fieldWizard for details.

placeholder

placeholder
Type
string
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['placeholder']
Scope
Display

Placeholder text for the field.

readOnly

readOnly
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display

Renders the field in a way that the user can see the values but cannot edit them. The rendering is as similar as possible to the normal rendering but may differ in layout and size.

This value can be overridden by page TSconfig.

required

required
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['required']
Scope
Display / Proc.
Default
false

If set to true a non-empty value is required in the field. Otherwise the form cannot be saved.

rows

rows
Type
integer
Default
5
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['rows']
Scope
Display

The number of rows in the JSON editor. May be corrected for harmonization between browsers. Will also automatically be increased if the content in the field is found to be of a certain length, thus the field will automatically fit the content. Default is 5. Max value is 20.

This value can be overridden by page TSconfig.