eval

eval (type => text)
Path

$GLOBALS['TCA'][$table]['columns'][$field]['config']

Type

string (list of keywords)

Scope

Display / Proc.

RenderType

default

Configuration of field evaluation. None of these apply for RTE fields.

Some of these evaluation keywords will trigger a JavaScript pre-evaluation in the form. Other evaluations will be performed in the backend.

The evaluation functions will be executed in the list-order, available keywords:

trim

The value in the field will have white spaces around it trimmed away.

Vendor\Extension\*

User defined form evaluations.

Deprecated since version 12.0: The keyword required is deprecated. Use the common property required instead.

Deprecated since version 12.0: The keyword null is deprecated. Use the property nullable (type => text) instead.

Examples

Trimming input

Trimming the value for white space before storing in the database:

../../../../_images/Text7.png
EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
'columns' => [
    'text_7' => [
        'exclude' => 1,
        'label' => 'text_7',
        'description' => 'eval=trim',
        'config' => [
            'type' => 'text',
            'eval' => 'trim',
        ],
    ],
]

Custom form evaluation

../../../../_images/Text9.png
EXT:styleguide/Configuration/TCA/tx_styleguide_elements_basic.php
'columns' => [
    'text_9' => [
        'exclude' => 1,
        'label' => 'text_9',
        'description' => 'readOnly=1',
        'config' => [
            'type' => 'text',
            'readOnly' => 1,
        ],
    ],
]

You can supply own form evaluations in an extension by creating a class with two functions: deevaluateFieldValue() called when opening the record and evaluateFieldValue() called for validation when saving the record:

EXT:styleguide/Classes/UserFunctions/FormEngine/TypeText9Eval.php

<?php

namespace TYPO3\CMS\Styleguide\UserFunctions\FormEngine;

class TypeText9Eval
{

    /**
     * Adds text "PHPfoo-evaluate" at end on saving
     *
     * @param string $value
     * @param string $is_in
     * @param bool $set
     * @return string
     */
    public function evaluateFieldValue($value, $is_in, &$set)
    {
        return $value . 'PHPfoo-evaluate';
    }

    /**
     * Adds text "PHPfoo-deevaluate" at end on opening
     *
     * @param array $parameters
     * @return string
     */
    public function deevaluateFieldValue(array $parameters)
    {
        $value = $parameters['value'];
        return $value . 'PHPfoo-deevaluate';
    }
}

EXT:styleguide/ext_localconf.php:

// Register the class to be available in 'eval' of TCA
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals']
   ['TYPO3\\CMS\\Styleguide\\UserFunctions\\FormEngine\\TypeText9Eval'] = '';