Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v10 here: TYPO3 ELTS.
format
format
-
- Type
- string (keyword) + array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Display
The value of a none-type fields is normally displayed as is. It is however possible to format it using this property. The following keywords are available, some having sub-properties. Sub-properties are called with the
format.
keyword (note the trailing dot), which in itself is an array.- date
-
Formats the value of the field as a date. The default formatting uses PHP's
date
function and() d-
as a format.m- Y Possible options are:
- strftime
- (boolean) If true,
strftime
is used instead() date
for formatting.() - option
- (string) Format string (i.e.
Y-
orm- d %x
, etc.). - appendAge
- (boolean) If true, the age of the value is appended is appended to the formatted output.
- datetime
- Formats the values using PHP's
date
function and() H:
as a format.i d- m- Y - time
- Formats the values using PHP's
date
function and() H:
as a format.i - timesec
- Formats the values using PHP's
date
function and() H:
as a format.i: s - year
- Formats the values using PHP's
date
function and() Y
as a format. - int
-
Formats the values as an integer using PHP's
sprintf
in various bases. The default base is decimal (() dec
). The base is defined as an option:- base
- (string) Defines the base of the value. Possible bases are "dec", "hex", "HEX", "oct" and "bin".
- float
-
Formats the values as an real number using PHP's
sprintf
and the() %f
marker. The number of decimals is an option:- precision
- (integer) Defines the number of decimals to use (maximum is 10, default is 2).
- number
-
Formats the values as a number using PHP's
sprintf
. The format to use is an option:() - option
- (string) A format definition according to PHP's
sprintf
function (see the reference).()
- md5
- Returns the md5 hash of the values.
- filesize
-
Formats the values as file size using
\TYPO3\
. One option exists:CMS\ Core\ Utility\ General Utility:: format Size () - appendByteSize
- (boolean) If true, the original value is appended to the formatted string (between brackets).
- user
-
Calls a user-defined function to format the values. The only option is the reference to the function:
- userFunc
- (string) Reference to the user-defined function. The function receives the field configuration and the field's value as parameters.
Examples
'aField' => [
'config' => [
'type' => 'none',
'format' => 'date'
'format.' => [
'strftime' => TRUE,
'option' => '%x'
],
],
],
'aField' => [
'config' => [
'type' => 'none',
'format' => 'float'
'format.' => [
'precision' => 8
],
],
],
'aField' => [
'config' => [
'type' => 'none',
'format' => 'user',
'format.' => [
'userFunc' => 'Evoweb\Example\Utility\MyCustomValue->getErrorMssg',
],
],
],