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.

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

behaviour

allowLanguageSynchronization

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_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/someTable.php
<?php

$numberField = [
    'config' => [
        'type' => 'number',
        'behaviour' => [
            'allowLanguageSynchronization' => true,
        ],
    ],
];
Copied!

autocomplete

autocomplete
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display
Default
false

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:

<?php

$temporaryColumns['numberField'] = [
    'label' => 'Integer field with autocomplete',
    'config' => [
        'type' => 'number',
        'size' => 20,
        'nullable' => true,
        'autocomplete' => true,
    ],
];
Copied!

default

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 number gets selected.

fieldControl

fieldControl

For details see fieldControl.

fieldInformation

fieldInformation

For details see fieldInformation.

fieldWizard

fieldWizard

defaultLanguageDifferences

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

For details see defaultLanguageDifferences.

localizationStateSelector

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

For details see localizationStateSelector.

otherLanguageContent

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

For details see otherLanguageContent.

format

format
Type
string (keyword)
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
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

mode
Type
string (keywords)
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

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

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

Example: A nullable number field
EXT:some_extension/Configuration/TCA/tx_sometable.php
<?php

$temporaryColumns['numberField'] = [
    'label' => 'Integer field with autocomplete',
    'config' => [
        'type' => 'number',
        'size' => 20,
        'nullable' => true,
        'autocomplete' => true,
    ],
];
Copied!

range

range
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
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: Limit an integer to be within the range 10 to 1000
'aField' => [
    'label' => 'aLabel',
    'config' => [
        'type' => 'number',
        'range' => [
            'lower' => 10,
            'upper' => 1000
        ],
    ],
],
Copied!

readOnly

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.

required

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

size
Type
integer
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
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

slider
Type
array
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
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: Integer slider between 0 and 100
<?php

$temporaryColumns['numberField'] = [
    'label' => 'Percent (0-100)',
    'config' => [
        'type' => 'number',
        'range' => [
            'lower' => 0,
            'upper' => 100,
        ],
        'slider' => [
            'step' => 1,
        ],
    ],
];
Copied!
Example: Integer slider between 0 and 10 000
<?php

$temporaryColumns['numberField'] = [
    'label' => 'A number between 0 and 10 000',
    'config' => [
        'type' => 'number',
        'slider' => [
            'step' => 1,
        ],
    ],
];
Copied!
Example: Decimal slider between 0 and 1
<?php

$temporaryColumns['numberField'] = [
    'label' => 'Number field with decimal slider',
    'config' => [
        'type' => 'number',
        'format' => 'decimal',
        'range' => [
            'lower' => 0,
            'upper' => 1,
        ],
        'slider' => [
            'step' => 0.1,
        ],
    ],
];
Copied!

valuePicker

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:

mode (keyword)
blank (or not set)
The selected value substitutes the value in the input field
append
The selected value is appended to an existing value of the input field
prepend
The selected value is prepended to an existing value of the input field
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 value transferred to the input field.
Example: Number field with value picker
<?php

$temporaryColumns['numberField'] = [
    'label' => 'Number field',
    'config' => [
        'type' => 'number',
        'mode' => '',
        'valuePicker' => [
            'items' => [
                ['One', '1'],
                ['Two', '2'],
            ],
        ],
    ],
];
Copied!