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_
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:
[
'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',
],
],
],
]
Properties of the TCA column type json
behaviour
-
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_
. It tells the DataHandler which fields of the localization records should be kept in sync if the underlying default or source record changes.state
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
-
- Type
- string
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['default']
Default value set if a new record is created.
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
-
- Type
- string
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldControl']
See fieldControl for details.
fieldInformation
-
- Type
- string
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldInformation']
See fieldInformation for details.
fieldWizard
-
- Type
- string
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']
See fieldWizard for details.
placeholder
-
- Type
- string
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['placeholder']
- Scope
- Display
Placeholder text for the field.
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.
Warning
This property affects only the display. It is still possible to write to those fields when using the DataHandler.
This value can be overridden by page TSconfig.
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
-
- 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.