Color
New in version 13.0
When using the color
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.
The TCA type color
should be used to render a JavaScript-based color picker.
The according database field
is generated automatically.
New in version 13.0
Color palettes have been added.
Color palettes can be defined via page TSconfig. This way, for example, colors defined in a corporate design can be selected by a simple click.
Table of contents
Example: Define a simple color picker in TCA
A simple color picker:
$aColorField' = [
'label' => 'Color field',
'config' => [
'type' => 'color',
]
];
Properties of the TCA column type color
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
default
-
- Type
- string
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['default']
- Scope
- Display / Proc.
Default value set if a new record is created. If empty, no color gets selected.
fieldControl
-
For details see fieldControl.
fieldInformation
-
For details see fieldInformation.
fieldWizard
-
defaultLanguageDifferences
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['defaultLanguageDifferences']
For details see defaultLanguageDifferences.
localizationStateSelector
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['localizationStateSelector']
For details see localizationStateSelector.
otherLanguageContent
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['otherLanguageContent']
For details see otherLanguageContent.
mode
-
- Type
- string (keywords)
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['mode']
- Scope
- Display
Possible keywords:
use
Or Override Placeholder This property is related to the
placeholder
property. When defined, a checkbox will appear above the field. If that box is checked, the field can be used to enter whatever the user wants as usual. If the box is not checked, the field becomes read-only and the value saved to the database will beNULL
.Warning
In order for this property to apply properly, the DB column must be allowed to be
NULL
, and propertynullable
must be set totrue
.
nullable
-
- Type
- boolean
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Default
- false
- Scope
- Proc
If set to true, a checkbox will appear, which by default deactivates the field. In the deactivated state the field is saved as
NULL
in the database. By activating the checkbox it is possible to set a value. If nothing is entered into the field, then an empty string will be saved and not aNULL
.The database field must allow the
NULL
value.
Example:
.. _columns-color-properties-nullable:
.. confval:: nullable
:name: color-nullable
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: boolean
:Default: false
:Scope: Proc
If set to true, a checkbox will appear, which by default deactivates the
field. In the deactivated state the field is saved as :sql:`NULL` in the
database. By activating the checkbox it is possible to set a value.
If nothing is entered into the field, then an empty string will be
saved and not a :sql:`NULL`.
The database field must allow the :sql:`NULL` value.
Example:
.. literalinclude:: _Properties/_Nullable.rst.txt
:caption: EXT:some_extension/Configuration/TCA/tx_sometable.php
opacity
-
- Type
- bool
- Default
- false
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['opacity']
New in version 13.3
If enabled, editors can select not only a color but also adjust its opacity (how transparent the color should be) in a color element.
Colors with an opacity are saved with the the
RRGGBBAA
color notation.
$temporaryColumns['aColorField'] = [
'label' => 'My Color',
'config' => [
'type' => 'color',
'opacity' => true,
],
];
placeholder
-
- Type
- string, hexadecimal color representation
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['placeholder']
- Scope
- Display
readOnly
-
- Type
- boolean
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['readOnly']
- Scope
- Display
Renders the field in a way that the user can see the value but cannot edit it.
Warning
This property affects only the display. It is still possible to write to those fields when using the DataHandler.
required
-
- Type
- boolean
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Display / Proc.
- Default
- false
If set to true a non-empty value is required in the field. Otherwise the form cannot be saved.
size
-
- Type
- integer
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Display
Abstract value for the width of the
<input>
field. To set the field to the full width of the form area, use the value 50. Minimum is 10. Default is 30.
valuePicker
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Display
Renders a select box with static values next to the input field. When a value is selected in the box, the value is transferred to the field. Keys:
- items (array)
- An array with selectable items. Each item is an array with the first value being the label in the select drop-down (LLL reference possible) the second being the hex-value transferred to the input field. The value should have exactly 7 characters, as this is the maximum for a hex-value.