type = 'user'

Introduction

Allows to render a whole form field by a developer defined class method.

Note

type='user' is outdated and currently mostly only kept for compatibility reasons. The 'renderType' approach which can be extended by extensions is much more powerful. See FormEngine for details.

Examples

A sample user-defined field

A sample user-defined field

TCA configuration:

'tx_examples_special' => [
    'label' => 'LLL:EXT:examples/Resources/Private/Language/locallang_db.xlf:fe_users.tx_examples_special',
    'config' => [
        'type' => 'user',
        'userFunc' => Documentation\Examples\Userfuncs\Tca::class . '->specialField',
        'parameters' => [
            'color' => 'blue'
        ],
    ],
],

This is how the corresponding PHP method in class \Documentation\Examples\Userfuncs\Tca looks like:

public function specialField($PA, $fObj)
{
    $color = (isset($PA['parameters']['color'])) ? $PA['parameters']['color'] : 'red';
    $formField  = '<div style="padding: 5px; background-color: ' . $color . ';">';
    $formField .= '<input type="text" name="' . $PA['itemFormElName'] . '"';
    $formField .= ' value="' . htmlspecialchars($PA['itemFormElValue']) . '"';
    $formField .= ' onchange="' . htmlspecialchars(implode('', $PA['fieldChangeFunc'])) . '"';
    $formField .= $PA['onFocus'];
    $formField .= ' /></div>';
    return $formField;
}

renderType default

type='check' has (currently) only one render definition, no special renderType must be set.

noTableWrapping

Datatype
boolean
Scope
Display
Description
If set to true, the output from the user function will not be wrapped in the usual table - you will have to do that yourself.

parameters

Datatype
array
Scope
Display / Proc.
Description
Array passed to the userFunc as the "parameters" key of the first argument received by the user function.

userFunc

Datatype
string (class->method reference)
Scope
Display / Proc.
Description

[classname]->[methodname]

Two arguments will be passed: The first argument is an array (passed by reference) which contains information about the current field being rendered. The second argument is a reference to the parent object, an instance of the TYPO3\CMS\Backend\Form\Element\UserElement wrapper class.

The array with current information will contain any parameters declared with the "parameters" property.