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)effective
(correct page ID)Pid site
(current site)
The following parameter only exists if the field has a flex parent.
flex
Parent Database Row
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' => [
['label' => 'foo', 'value' => 1],
['label' => 'bar', 'value' => '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'][] = ['label' => 'item 1 from itemProcFunc()', 'value' => 'val1'];
$params['items'][] = ['label' => 'item 2 from itemProcFunc()', 'value' => '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.