The none field

There are three columns config types that do similar things but still have subtle differences between them. These are the none type, the passthrough type and the user type.

Characteristics of none:

  • The DataHandler discards values send for type none and never persists or updates them in the database.
  • Type none is the only type that does not necessarily need a database field.
  • Type none fields does have a default renderType in FormEngine that displays the value as readonly if a database field exists and the value can be formatted.
  • If no database field exists for none fields, an empty readonly input field is rendered by default.
  • Type none fields are designed to be not rendered at other places in the backend, for instance they can not be selected to be displayed in the list module "single table view" if everything has been configured correctly.

The none field can be useful, if:

  • A "virtual" field that has no database representation is needed. A simple example could be a rendered map that receives values from latitude and longitude fields but that needs to database representation itself.
  • A third party feeds the database field with a value and the value should be formatted and displayed in FormEngine. However, a input type with readOnly=true is usually better suited to do that.

Since the formatting part of none fields can be done with input type as well, most useful usage of type none fields is a "virtual" field that is combined with a custom renderType by an extension. The TYPO3 core makes little or no use of none fields itself.

Example: Simple none field

EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
[
    'columns' => [
        'none_1' => [
            'label' => 'none_1',
            'description' => 'default',
            'config' => [
                'type' => 'none',
            ],
        ],
    ],
]
Copied!

Properties of the TCA column type none

Name Type Scope
string (keyword) + array Display
boolean Display
integer Display

fieldInformation

fieldInformation

For details see fieldInformation.

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-m-Y as a format.

Possible options are:

strftime
(boolean) If true, strftime() is used instead date() for formatting.
option
(string) Format string (i.e. Y-m-d or %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:i d-m-Y as a format.
time
Formats the values using PHP's date() function and H:i as a format.
timesec
Formats the values using PHP's date() function and H:i:s as a format.
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\CMS\Core\Utility\GeneralUtility::formatSize(). One option exists:

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 .. code-block:: php

'aField' => [
'config' => [
'type' => 'none', 'format' => 'date' 'format.' => [ 'strftime' => TRUE, 'option' => '%x' ],

],

],

'aField' => [
  'config' => [
     'type' => 'none',
     'format' => 'float'
     'format.' => [
        'precision' => 8
     ],
  ],
],
Copied!
'aField' => [
  'config' => [
    'type' => 'none',
    'format' => 'user',
    'format.' => [
        'userFunc' => 'Evoweb\Example\Utility\MyCustomValue->getErrorMssg',
    ],
  ],
],
Copied!

Deprecated since version 12.2

Instances with field configs for type="none" having key pass_content will trigger a deprecation warning during TCA cache warmup. The option will be removed with TYPO3 v13.

pass_content

pass_content
Type
boolean
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display

If set, then content from the field is directly outputted in the <input> section as value attribute. Otherwise, the content will be passed through htmlspecialchars().

Be careful to set this flag since it allows HTML from the field to be outputted on the page, thereby creating the possibility of XSS security holes.

size

size
Type
integer
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
Scope
Display

Value for the width of the <input> field. To set the input field to the full width of the form area, use the value 50. Default is 30.

Changed in version 12.0

The TCA type none had two option keys for the same functionality: cols and size. In order to simplify the available configuration, cols has been dropped in favour of size.

Migration

Rename the option cols to size.

  'columns' => [
      'aColumn' => [
          'config' => [
              'type' => 'none',
-             'cols' => 20,
+             'size' => 20,
          ],
      ],
  ],
Copied!