Number 

New in version 13.0

The TCA type number should be used to input values representing numbers.

The according database field is generated automatically.

Table of contents:

Properties of the TCA column type number 

Name Type Scope
boolean Proc.
boolean Display
string Display / Proc.
array
array
array
string (keyword) Display
string (keywords) Display
boolean Proc.
array Proc.
boolean Display
boolean Display / Proc.
integer Display
array Display
array 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/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',
);
Copied!
autocomplete
Type
boolean
Default
false
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['autocomplete']
Scope
Display

Controls the autocomplete attribute of a given number field. If set to true, adds attribute autocomplete="on" to the number input field allowing browser auto filling the field:

'autocomplete' => true,
Copied!
default
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.

fieldControl

For details see fieldControl.

fieldInformation

For details see fieldInformation.

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

For details see defaultLanguageDifferences.

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

For details see localizationStateSelector.

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

For details see otherLanguageContent.

format
Type
string (keyword)
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['format']
Scope
Display

Keywords: integer, decimal

The format property defines, which type of number should be handled. The integer format is a simple number, whereas the decimal format is a float value with two decimal places.

mode
Type
string (keywords)
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['mode']
Scope
Display

Possible keywords: useOrOverridePlaceholder

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 be NULL .

nullable
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 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 NULL .

The if database field is created automatically, it allow the NULL value.

Example: No limit for the participants unless one is set
EXT:my_extension/Configuration/TCA/Overrides/245-tx_myextension_talk-max_participants.php
<?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',
);
Copied!
range
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.

Example: A conference has between 1 and 5000 seats
EXT:my_extension/Configuration/TCA/Overrides/145-tx_myextension_conference-seats.php
<?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',
);
Copied!
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 value but cannot edit it.

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.

size
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.

slider
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.
Example: A duration between 5 and 240 minutes in steps of 5
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',
);
Copied!
Example: Slider without a range, between 0 and 10 000
'slider' => [
  'step' => 1,
],
Copied!
Example: Decimal slider between 0 and 1

The priority of a conference in the XML sitemap goes from 0.0 to 1.0 in steps of 0.1:

EXT:my_extension/Configuration/TCA/Overrides/108-tx_myextension_conference-sitemap_priority.php
<?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
      'format' => 'decimal',
      'range' => [
        'lower' => 0,
        'upper' => 1,
      ],
      'slider' => [
        'step' => 0.1,
      ],
      'default' => 0.5,
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_conference',
  'sitemap_priority',
  '',
  'after:slug',
);
Copied!
valuePicker
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 items using label and value. Existing numeric arrays are automatically migrated during TCA processing.

The mode option no longer supports append or prepend. The Value Picker always behaves like a replace operation. Any legacy mode setting 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.
Example: Typical capacities to choose from
The capacity of a location with its value picker opened

The capacity of a location with its value picker opened

EXT:my_extension/Configuration/TCA/Overrides/425-tx_myextension_location-capacity.php
<?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',
);
Copied!