Number
New in version 13.0
When using the number 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.
The TCA type number should be used to input values representing numbers.
It holds integers, or decimal numbers with the number of decimal digits
set in scale.
The according database field is generated automatically.
Note
The slider option allows to define a visual slider element, next to the input field. The steps can be defined with the slider[step] option. The minimum and maximum value can be configured with the range[lower] and range[upper] options.
Table of contents:
Properties of the TCA column type number
| Name | Type | Scope |
|---|---|---|
| boolean | Proc. | |
| boolean | Display | |
| string | Display / Proc. | |
| array | ||
| array | ||
| array | ||
| string (keywords) | Display | |
| boolean | Proc. | |
| array | Proc. | |
| boolean | Display | |
| boolean | Display / Proc. | |
| integer | Display / Proc. | |
| integer | Display | |
| array | Display | |
| array | Display |
-
-
- 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_. It tells the DataHandler which fields of the localization records should be kept in sync if the underlying default or source record changes.state EXT:my_extension/Configuration/TCA/Overrides/220-tx_myextension_talk-duration.php<?php use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; defined('TYPO3') or die(); ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [ 'duration' => [ 'label' => 'my_extension.db:talk.duration', 'config' => [ 'type' => 'number', 'range' => [ 'lower' => 5, 'upper' => 240, ], 'slider' => [ 'step' => 5, ], 'default' => 45, 'behaviour' => [ 'allowLanguageSynchronization' => true, ], ], ], ]); $GLOBALS['TCA']['tx_myextension_talk']['types']['workshop']['columnsOverrides']['duration']['config']['default'] = 180; ExtensionManagementUtility::addToAllTCAtypes( 'tx_myextension_talk', 'duration', '', 'after:start_time', );
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['autocomplete']
- Scope
- Display
Controls the
autocompleteattribute of a given number field. If set to true, adds attributeautocomplete="on"to the number input field allowing browser auto filling the field:'autocomplete' => true,Copied!
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['default']
- Scope
- Display / Proc.
Default value set if a new record is created. If empty, no number gets selected.
-
For details see fieldControl.
-
For details see fieldInformation.
-
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['defaultLanguageDifferences']
For details see defaultLanguageDifferences.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['localizationStateSelector']
For details see localizationStateSelector.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['fieldWizard']['otherLanguageContent']
For details see otherLanguageContent.
-
- Type
- string (keywords)
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['mode']
- Scope
- Display
Possible keywords:
useOr Override Placeholder This property is related to the
placeholderproperty. 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 propertynullablemust be set totrue.
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['nullable']
- 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
NULLin 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 if database field is created automatically, it allow the
NULLvalue.
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [
'max_participants' => [
'label' => 'my_extension.db:talk.max_participants',
'config' => [
'type' => 'number',
'nullable' => true,
'range' => [
'lower' => 1,
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_talk',
'max_participants',
'workshop',
'before:--div--;core.form.tabs:access',
);
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['range']
- Scope
- Proc.
An array which defines an integer range within which the value must be. Keys:
- lower
- Defines the lower integer value.
- upper
- Defines the upper integer value.
It is allowed to specify only one of both of them.
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'seats' => [
'label' => 'my_extension.db:conference.seats',
'displayCond' => [
'AND' => [
'FIELD:sys_language_uid:=:0',
'OR' => [
'FIELD:event_format:=:onsite',
'FIELD:event_format:=:hybrid',
],
],
],
'config' => [
'type' => 'number',
'range' => [
'lower' => 1,
'upper' => 5000,
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'seats',
'',
'before:--div--;core.form.tabs:categories',
);
-
- 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 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.
-
- 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.
-
- Type
- integer
- Default
- 0
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['scale']
- Scope
- Display / Proc.
- Added
- 15.0, Feature: #102217 - Configurable scale for TCA type "number"
The number of decimal digits. With the default
0, the field holds an integer. The scale is between0and30. A value outside this range is set to the nearest limit.The scale applies wherever the value is handled:
- The automatically generated database column is an
intfor a scale of0. For a higher scale, it is adecimalwith eight digits in front of the decimal point, plus the scale. A scale of6gives adecimal.(14,6) - The
Datarounds every value it saves to the scale. A column declared with more decimal digits inHandler ext_tables.sqlloses them on the next save. - The input field in the backend form uses the scale as its
stepattribute, for examplestep="0.for a scale of000001" 6. Browsers cannot check a step below1e-. For a scale above18 18, the field hasstep="any", and the browser does not restrict the value.
When you lower the scale of an existing field, stored values can have more decimal digits than the scale. The backend form shows such a value rounded, and the next save of the record stores it rounded. MySQL and PostgreSQL round the stored values when the column is changed. SQLite keeps decimal values as strings and does not round them.
Six decimal digits put a geographic position on a grid of about ten centimetres:
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_location', [
'latitude' => [
'label' => 'my_extension.db:location.latitude',
'config' => [
'type' => 'number',
'scale' => 6,
],
],
'longitude' => [
'label' => 'my_extension.db:location.longitude',
'config' => [
'type' => 'number',
'scale' => 6,
],
],
]);
$GLOBALS['TCA']['tx_myextension_location']['palettes']['coordinates'] = [
'label' => 'my_extension.db:location.palette.coordinates',
'description' => 'my_extension.db:location.palette.coordinates.description',
'showitem' => 'latitude, longitude',
];
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_location',
'--palette--;;coordinates',
'',
'after:country',
);
-
- Type
- integer
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['size']
- Scope
- Display
Abstract value for the width of the
<input>field. To set the number field to the full width of the form area, use the value 50. Minimum is 10. Default is 30.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['slider']
- Scope
- Display
Render a value slider next to the field.
It is advised to also define a range property, otherwise the slider will go from 0 to 10000. Note the range can be negative if needed. Available keys:
- step (integer / float)
- Set the step size the slider will use. For floating point values this can itself be a floating point value.
- width (integer, pixels)
- Define the width of the slider.
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [
'duration' => [
'label' => 'my_extension.db:talk.duration',
'config' => [
'type' => 'number',
'range' => [
'lower' => 5,
'upper' => 240,
],
'slider' => [
'step' => 5,
],
'default' => 45,
'behaviour' => [
'allowLanguageSynchronization' => true,
],
],
],
]);
$GLOBALS['TCA']['tx_myextension_talk']['types']['workshop']['columnsOverrides']['duration']['config']['default'] = 180;
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_talk',
'duration',
'',
'after:start_time',
);
'slider' => [
'step' => 1,
],
The priority of a conference in the XML sitemap goes from 0.0 to 1.0 in steps of 0.1:
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'sitemap_priority' => [
'label' => 'my_extension.db:conference.sitemap_priority',
'config' => [
'type' => 'number',
// The priority in an XML sitemap goes from 0.0 to 1.0
'scale' => 1,
'range' => [
'lower' => 0,
'upper' => 1,
],
'slider' => [
'step' => 0.1,
],
'default' => 0.5,
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'sitemap_priority',
'',
'after:slug',
);
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['valuePicker']
- Scope
- Display
Renders a select box with static values next to the input field. When an item is selected, the value replaces the current input value.
Changed in version 14.0 Breaking: #107677 - Drop prepend and append modes from TCA value picker
It is now recommended to define associative array keys for
itemsusinglabelandvalue. Existing numeric arrays are automatically migrated during TCA processing.The
modeoption no longer supportsappendorprepend. The Value Picker always behaves like a replace operation. Any legacymodesetting is ignored.- items (array)
- A list of selectable items. Each item should be an associative array:
['label' => 'Shown label', 'value' => 123]. The label can be plain text or a label reference.
The capacity of a location with its value picker opened
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_location', [
'capacity' => [
'label' => 'my_extension.db:location.capacity',
'config' => [
'type' => 'number',
'range' => [
'lower' => 1,
],
'valuePicker' => [
'items' => [
['label' => '50', 'value' => 50],
['label' => '100', 'value' => 100],
['label' => '250', 'value' => 250],
['label' => '500', 'value' => 500],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_location',
'capacity',
'',
'after:directions',
);