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.
itemsProcFunc
itemsProcFunc
-
- Path
-
$GLOBALS['TCA'][$table]['columns'][$field]['config']
- type
-
string (class->method reference)
- Scope
-
Display / Proc.
- Types
PHP method which is called to fill or manipulate the items array. It is recommended to use the actual FQCN with
class
and then concatenate the method:\VENDOR\
Extension\ User Function\ Form Engine\ Your Class:: class . '->your Method' This becomes handy when using an IDE and doing operations like renaming classes.
The provided method will have an array of parameters passed to it. The items array is passed by reference in the key
items
. By modifying the array of items, you alter the list of items. A method may throw an exception which will be displayed as a proper error message to the user.
Passed parameters
items
(passed by reference)config
(TCA config of the field)TSconfig
(The matching itemsProcFunc TSconfig)table
(current table)row
(current database record)field
(current field name)
The following parameter only exists if the field has a flex parent.
flex
Parent Database Row
New in version 11.2
The following parameters are filled if the current record has an inline parent.
inline
Parent Uid inline
Parent Table Name inline
Parent Field Name inline
Parent Config inline
Top Most Parent Uid inline
Top Most Parent Table Name inline
Top Most Parent Field Name
Example
The configuration for a custom field select_
could look like this:
'select_single_2' => [
'exclude' => 1,
'label' => 'select_single_2 itemsProcFunc',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['foo', 1],
['bar', 'bar'],
],
'itemsProcFunc' => TYPO3\CMS\Styleguide\UserFunctions\FormEngine\TypeSelect2ItemsProcFunc::class . '->itemsProcFunc',
],
]
The referenced items
method should populate the items by filling $params
:
/**
* A user function used in select_2
*/
class TypeSelect2ItemsProcFunc
{
/**
* Add two items to existing ones
*
* @param array $params
*/
public function itemsProcFunc(&$params): void
{
$params['items'][] = ['item 1 from itemProcFunc()', 'val1'];
$params['items'][] = ['item 2 from itemProcFunc()', 'val2'];
}
}
This results in the rendered select dropdown having four items. This is a really simple example. In the real world you would use the other passed parameters to dynamically generate the items.