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 Content > Records 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.

Table of contents:

Example: Simple none field 

A comment shows when it was written. The column crdate exists, as the ctrl section of the comments names it, and TYPO3 sets its value. The field of type none only displays it:

The time a comment was written

The time a comment was written

EXT:my_extension/Configuration/TCA/Overrides/520-tx_myextension_comment-crdate.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

// Shows when a comment was written. TYPO3 sets the value, an editor
// cannot change it.
ExtensionManagementUtility::addTCAcolumns('tx_myextension_comment', [
  'crdate' => [
    'label' => 'my_extension.db:comment.crdate',
    'config' => [
      'type' => 'none',
      'format' => 'datetime',
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_comment',
  'crdate',
  '',
  'after:name',
);
Copied!

Properties of the TCA column type none 

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

For details see fieldInformation.

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

The time a comment was written:

EXT:my_extension/Configuration/TCA/Overrides/520-tx_myextension_comment-crdate.php
<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

// Shows when a comment was written. TYPO3 sets the value, an editor
// cannot change it.
ExtensionManagementUtility::addTCAcolumns('tx_myextension_comment', [
  'crdate' => [
    'label' => 'my_extension.db:comment.crdate',
    'config' => [
      'type' => 'none',
      'format' => 'datetime',
    ],
  ],
]);
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_comment',
  'crdate',
  '',
  'after:name',
);
Copied!

The feedback form of the website stores when it opened for a talk, the average rating, and the number of feedback forms. The editors only read them:

EXT:my_extension/Configuration/TCA/Overrides/298-tx_myextension_talk-feedback.php
<?php

use MyVendor\MyExtension\Backend\FeedbackCountFormatter;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

// The feedback form of the website stores these values, the editors only
// read them
ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [
  'feedback_opened' => [
    'label' => 'my_extension.db:talk.feedback_opened',
    'config' => [
      'type' => 'none',
      // For example "05/12/2027 (5 days)"
      'format' => 'date',
      'format.' => [
        'strftime' => true,
        'option' => '%x',
        'appendAge' => true,
      ],
    ],
  ],
  'rating' => [
    'label' => 'my_extension.db:talk.rating',
    'config' => [
      'type' => 'none',
      // The average of all ratings, for example "4.3"
      'format' => 'float',
      'format.' => [
        'precision' => 1,
      ],
    ],
  ],
  'feedback_count' => [
    'label' => 'my_extension.db:talk.feedback_count',
    'config' => [
      'type' => 'none',
      // For example "12 attendees"
      'format' => 'user',
      'format.' => [
        'userFunc' => FeedbackCountFormatter::class . '->format',
      ],
    ],
  ],
]);
$GLOBALS['TCA']['tx_myextension_talk']['palettes']['feedback'] = [
  'label' => 'my_extension.db:talk.feedback',
  'showitem' => 'feedback_opened, rating, feedback_count',
];
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_talk',
  '--palette--;;feedback',
  'talk,keynote',
  'after:comments_closed',
);
// In a workshop, the participants give the feedback
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_talk',
  '--palette--;my_extension.db:talk.feedback.workshop;feedback',
  'workshop',
  'after:comments_closed',
);
Copied!
EXT:my_extension/Configuration/TCA/Overrides/298-tx_myextension_talk-feedback.php
<?php

use MyVendor\MyExtension\Backend\FeedbackCountFormatter;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

// The feedback form of the website stores these values, the editors only
// read them
ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [
  'feedback_opened' => [
    'label' => 'my_extension.db:talk.feedback_opened',
    'config' => [
      'type' => 'none',
      // For example "05/12/2027 (5 days)"
      'format' => 'date',
      'format.' => [
        'strftime' => true,
        'option' => '%x',
        'appendAge' => true,
      ],
    ],
  ],
  'rating' => [
    'label' => 'my_extension.db:talk.rating',
    'config' => [
      'type' => 'none',
      // The average of all ratings, for example "4.3"
      'format' => 'float',
      'format.' => [
        'precision' => 1,
      ],
    ],
  ],
  'feedback_count' => [
    'label' => 'my_extension.db:talk.feedback_count',
    'config' => [
      'type' => 'none',
      // For example "12 attendees"
      'format' => 'user',
      'format.' => [
        'userFunc' => FeedbackCountFormatter::class . '->format',
      ],
    ],
  ],
]);
$GLOBALS['TCA']['tx_myextension_talk']['palettes']['feedback'] = [
  'label' => 'my_extension.db:talk.feedback',
  'showitem' => 'feedback_opened, rating, feedback_count',
];
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_talk',
  '--palette--;;feedback',
  'talk,keynote',
  'after:comments_closed',
);
// In a workshop, the participants give the feedback
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_talk',
  '--palette--;my_extension.db:talk.feedback.workshop;feedback',
  'workshop',
  'after:comments_closed',
);
Copied!
EXT:my_extension/Configuration/TCA/Overrides/298-tx_myextension_talk-feedback.php
<?php

use MyVendor\MyExtension\Backend\FeedbackCountFormatter;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3') or die();

// The feedback form of the website stores these values, the editors only
// read them
ExtensionManagementUtility::addTCAcolumns('tx_myextension_talk', [
  'feedback_opened' => [
    'label' => 'my_extension.db:talk.feedback_opened',
    'config' => [
      'type' => 'none',
      // For example "05/12/2027 (5 days)"
      'format' => 'date',
      'format.' => [
        'strftime' => true,
        'option' => '%x',
        'appendAge' => true,
      ],
    ],
  ],
  'rating' => [
    'label' => 'my_extension.db:talk.rating',
    'config' => [
      'type' => 'none',
      // The average of all ratings, for example "4.3"
      'format' => 'float',
      'format.' => [
        'precision' => 1,
      ],
    ],
  ],
  'feedback_count' => [
    'label' => 'my_extension.db:talk.feedback_count',
    'config' => [
      'type' => 'none',
      // For example "12 attendees"
      'format' => 'user',
      'format.' => [
        'userFunc' => FeedbackCountFormatter::class . '->format',
      ],
    ],
  ],
]);
$GLOBALS['TCA']['tx_myextension_talk']['palettes']['feedback'] = [
  'label' => 'my_extension.db:talk.feedback',
  'showitem' => 'feedback_opened, rating, feedback_count',
];
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_talk',
  '--palette--;;feedback',
  'talk,keynote',
  'after:comments_closed',
);
// In a workshop, the participants give the feedback
ExtensionManagementUtility::addToAllTCAtypes(
  'tx_myextension_talk',
  '--palette--;my_extension.db:talk.feedback.workshop;feedback',
  'workshop',
  'after:comments_closed',
);
Copied!

The user function receives the value of the field:

EXT:my_extension/Classes/Backend/FeedbackCountFormatter.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Backend;

use TYPO3\CMS\Core\Localization\LanguageService;

final class FeedbackCountFormatter
{
  /**
   * Shows the number of feedback forms as text, for example "12 attendees"
   */
  public function format(array $parameters): string
  {
    $count = (int)($parameters['value'] ?? 0);
    $label = $count === 1 ? 'talk.feedback_count.one' : 'talk.feedback_count.other';
    return sprintf($this->getLanguageService()->sL('my_extension.db:' . $label), $count);
  }

  private function getLanguageService(): LanguageService
  {
    return $GLOBALS['LANG'];
  }
}
Copied!
size
Type
integer
TCA path
$GLOBALS['TCA'][$table]['columns'][$field]['config']['size']
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.