itemsProcFunc

itemsProcFunc
Type:string (class->method reference)
Scope:Display / Proc.
Types:check, select, radio

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\UserFunction\FormEngine\YourClass::class . '->yourMethod'

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)

New in version 7.6.

The following parameter only exists if the field has a flex parent.

  • flexParentDatabaseRow

New in version 11.2.

The following parameters are filled if the current record has an inline parent.

  • inlineParentUid
  • inlineParentTableName
  • inlineParentFieldName
  • inlineParentConfig
  • inlineTopMostParentUid
  • inlineTopMostParentTableName
  • inlineTopMostParentFieldName

Example

The configuration for a custom field select_single_2 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 itemsProcFunc method should populate the items by filling $params['items']:

/**
 * 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.