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_
file.
The TCA type number
should be used to input values representing numbers.
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.
Properties of the TCA column type number
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
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 attributeautocomplete="on"
to the number input field allowing browser auto filling the field:
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
-
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.
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 thedecimal
format is a float value with two decimal places.
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 if database field is created automatically, it allow the
NULL
value.
<?php
$temporaryColumns['numberField'] = [
'label' => 'Integer field with autocomplete',
'config' => [
'type' => 'number',
'size' => 20,
'nullable' => true,
'autocomplete' => true,
],
];
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.
'aField' => [
'label' => 'aLabel',
'config' => [
'type' => 'number',
'range' => [
'lower' => 10,
'upper' => 1000
],
],
],
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 number field to the full width of the form area, use the value 50. Minimum is 10. Default is 30.
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.
<?php
$temporaryColumns['numberField'] = [
'label' => 'Percent (0-100)',
'config' => [
'type' => 'number',
'range' => [
'lower' => 0,
'upper' => 100,
],
'slider' => [
'step' => 1,
],
],
];
<?php
$temporaryColumns['numberField'] = [
'label' => 'A number between 0 and 10 000',
'config' => [
'type' => 'number',
'slider' => [
'step' => 1,
],
],
];
<?php
$temporaryColumns['numberField'] = [
'label' => 'Number field with decimal slider',
'config' => [
'type' => 'number',
'format' => 'decimal',
'range' => [
'lower' => 0,
'upper' => 1,
],
'slider' => [
'step' => 0.1,
],
],
];
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.