Bug #86985
openitemsProcFunc for select->selectSingle shows key instead of label in page translation
0%
Description
Hi,
I noticed that when using 'itemsProcFunc' I get a strange behaviour when translating a page. When translating the page in the BE then the key is shown instead of the label. This behaviour doesn't appear to be when using 'items' to render a select list. Shouldn't the label be shown instead of the key like it is for rendering lists with 'items'? Or am I missing an implementation step?
... // Here's the snippet from the tca where I override pages 'tx_abcde_blog_media_type' => [ 'exclude' => 0, 'label' => 'Blog type', 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', 'itemsProcFunc' => "XYZ\\Abcde\\Lists\\MediaTypes->tcaMediaTypes", ], 'displayCond' => 'FIELD:tx_abcde_blog_content_type:!=:category', ] ... // Here are the functions I am using static public function tcaMediaTypes($config){ $config['items'] = \XYZ\\Abcde\Helper\TCA::arrayToList(self::mediaTypes()); return $config; } static function mediaTypes() { return [ 0 => Languages::translate('blog.mediatypes.0'), 1 => Languages::translate('blog.mediatypes.1'), 2 => Languages::translate('blog.mediatypes.2'), 3 => Languages::translate('blog.mediatypes.3') ]; } public static function arrayToList($aArray) { $list = []; foreach ($aArray as $key => $value) { $list[] = [$value, $key]; } return $list; } ...
I attached a screenshot !Screen Shot 2018-11-23 at 11.50.23.png! to show the issue.
Files
Updated by Filipe DA COSTA almost 6 years ago
- Related to Bug #54131: getLabelsFromItemsList doens't return any values when no item found added
Updated by Filipe DA COSTA almost 6 years ago
I made some tests with a fresh Typo3 8.7.20 instance and can confirm the above issue.
TCA for `pages`:
$tca = [
'tx_apxsample_category' => [
'exclude' => 1,
'label' => 'Category',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'size' => '1',
'itemsProcFunc' => "Vendor\\Apxsample\\Lists\\Categories->tcaCategories",
]
],
'tx_apxsample_category2' => [
'exclude' => 1,
'label' => 'Category',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'size' => '1',
'items' => [
['Category A', 0 ],
['Category B', 1 ],
['Category C', 2 ],
['Category D', 3 ]
],
]
],
];
TCA for `pages_language_overlay`:
$tca = [
'tx_apxsample_category' => [
'exclude' => 1,
'label' => 'Category',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'size' => '1',
'itemsProcFunc' => "Vendor\\Apxsample\\Lists\\Categories->tcaCategories",
'behaviour' => [
'allowLanguageSynchronization' => 1
]
]
],
'tx_apxsample_category2' => [
'exclude' => 1,
'label' => 'Category',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'size' => '1',
'items' => [
['Category A', 0 ],
['Category B', 1 ],
['Category C', 2 ],
['Category D', 3 ]
],
'behaviour' => [
'allowLanguageSynchronization' => 1
]
]
],
];
Here's the list used by itemsProcFunc:
static public function tcaCategories($config){
$config['items'] = [
['Category A', 0 ],
['Category B', 1 ],
['Category C', 2 ],
['Category D', 3 ]
];
return $config;
}
Result of a translated page (see attached image)
`BackendUtility::getLabelsFromItemsList` does not support `itemsProcFunc` and it produces a display bug on `otherLanguageContent` field when working with a `select`.
The code that should return the label, only checks for `items` and does not try to process that `itemsProcFunc`: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/backend/Classes/Utility/BackendUtility.php#L1732
`BackendUtility::getLabelsFromItemsList` should also check if `itemsProcFunc` is in the config and call `GeneralUtility::callUserFunction` in that case. (I understand that some changes to callUserFunction could be needed, specially for the $ref part)
In the PHPDoc, there's `NOTE: this does not take itemsProcFunc into account`, but there's nothing about that in the documentation.
Updated by Gerrit Code Review almost 6 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59156
Updated by Gerrit Code Review almost 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59156
Updated by Gerrit Code Review almost 6 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59156
Updated by Gerrit Code Review almost 6 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59156
Updated by Gerrit Code Review almost 6 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59156
Updated by Gerrit Code Review almost 6 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59156
Updated by Gerrit Code Review almost 6 years ago
Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59156
Updated by Gerrit Code Review over 5 years ago
Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59156
Updated by Gerrit Code Review over 4 years ago
Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59156
Updated by Gerrit Code Review over 4 years ago
Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59156
Updated by Gerrit Code Review about 3 years ago
Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59156
Updated by Gerrit Code Review about 3 years ago
Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/59156