Json 

Renders a text area to enter json data.

The according database field is generated automatically.

Table of contents:

Example: Simple JSON field 

The social links of a speaker are stored as JSON:

The social links of a speaker

The social links of a speaker

EXT:my_extension/Configuration/TCA/Overrides/340-tx_myextension_speaker-social_links.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

ExtensionManagementUtility::addTCAcolumns('tx_myextension_speaker', [
  'social_links' => [
    'label' => 'my_extension.db:speaker.social_links',
    'config' => [
      'type' => 'json',
      'searchable' => false,
      'behaviour' => [
        'allowLanguageSynchronization' => true,
      ],
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_speaker',
  'social_links',
  '',
  'before:--div--;core.form.tabs:access',
);
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
boolean Display
behaviour
allowLanguageSynchronization
Type
boolean
Default
false
TCA 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/340-tx_myextension_speaker-social_links.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

ExtensionManagementUtility::addTCAcolumns('tx_myextension_speaker', [
  'social_links' => [
    'label' => 'my_extension.db:speaker.social_links',
    'config' => [
      'type' => 'json',
      'searchable' => false,
      'behaviour' => [
        'allowLanguageSynchronization' => true,
      ],
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_speaker',
  'social_links',
  '',
  'before:--div--;core.form.tabs:access',
);
Copied!
cols
Type
integer
Default
30
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['cols']
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
Type
string
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['default']

Default value set if a new record is created.

enableCodeEditor
Type
boolean
Default
true
TCA 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
Type
string
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']

See fieldControl for details.

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

See fieldInformation for details.

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

See fieldWizard for details.

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

Placeholder text for the field.

readOnly
Type
boolean
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['readOnly']
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
Type
boolean
Default
false
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['required']
Scope
Display / Proc.

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

rows
Type
integer
Default
5
TCA 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.

searchable
Type
boolean
Default
true
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['searchable']
Scope
Display

New in version 14.0

TYPO3 now automatically includes all fields of suitable types in backend search operations in the Content > Records module.

This option can be used to explicitly exclude fields from being searchable, instead of having to list them in the now removed option $GLOBALS['TCA'][$table]['ctrl']['searchFields'].

By default, all fields of type json are considered searchable. To exclude a field from being searchable, set the following in the field's TCA configuration:

EXT:my_extension/Configuration/TCA/Overrides/340-tx_myextension_speaker-social_links.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

ExtensionManagementUtility::addTCAcolumns('tx_myextension_speaker', [
  'social_links' => [
    'label' => 'my_extension.db:speaker.social_links',
    'config' => [
      'type' => 'json',
      'searchable' => false,
      'behaviour' => [
        'allowLanguageSynchronization' => true,
      ],
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_speaker',
  'social_links',
  '',
  'before:--div--;core.form.tabs:access',
);
Copied!