Bug #96461
openitemsProcFunc is not able to add itemGroups
0%
Description
Before itemGroups was introduced, it was possible to add a ['Some Label', '--div--'] option to add grouped items from itemsProcFunc. This is not fully supported anymore because you dont have access to the itemGroups configuration.
You can still add groups but have no possibility of adding labels.
Lets assume you have an "itemsProcFunc" method which takes one parameter called $config:
1) You cant manipulate $config['itemGroups'] because ItemProcessingService has no support for it
2) You can not manipulate $config['config']['itemGroups'] because it is not passed as reference
3) You can not use ExtensionManagementUtility::addTcaSelectItemGroup, it modifies the TCA as expected but TcaSelectItems::addData already works with a local copy of the field config
Current possible workarounds:
1) keep using ['LLL:label', '--div--']
con: will be deprecated, no future-proof solution
2) Dont use 'LLL:label' for the itemGroup Key, use the translated label
con: Does not "feel" right/consistant but works
3) Add the itemGroup via TCA Overrides
con: not as much straight-forward as it could be, more boilerplate code...
Possible solution:
A) pass the global TCA-config value to TcaSelectItems::groupAndSortItems
pro: Could alter itemGroups via ExtensionManagementUtility::addTcaSelectItemGroup
con: unpredictable side-effects possible
B) pass whole field config as reference
pretty much the same cons than A but the Utility method ExtensionManagementUtility::addTcaSelectItemGroup would not work
C) add itemGroups, sortItems and everything necessary to $processorParameters in AbstractItemProvider::resolveItemProcessorFunction
pro: you can alter itemGroups without any side-effects
con: The Utility method ExtensionManagementUtility::addTcaSelectItemGroup would not work
I would suggest Option C as a solution because it does only add some new options without changing anything else.
Updated by Jan Delius about 1 month ago
+1 for this. Its really bad that we can add items via a userFunc but not sort them correctly with custom labels given in a runtime filled itemGroups.