#86985itemsProcFunc for select->selectSingle shows key instead of label in page translation
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.
Reviews 1
Related issues 2
Files 2
History 517
-
Filipe DA COSTA changed Related to #54131 <span data-processor="relativetime" data-value="2018-11-27T11:55:14+00:00" > 11/27/18, 11:55 </span>
-
Filipe DA COSTA commented and changed attached Screenshot 2018-11-27 at 12.05.01.png <span data-processor="relativetime" data-value="2018-11-27T12:08:36+00:00" > 11/27/18, 12:08 </span>
-
Gerrit Code Review pushed patch set 1 for master to change 59156 status
NewUnder Review <span data-processor="relativetime" data-value="2018-12-14T14:53:13+00:00" > 12/14/18, 14:53 </span> -
Gerrit Code Review pushed patch set 2 for master to change 59156 <span data-processor="relativetime" data-value="2018-12-14T14:55:57+00:00" > 12/14/18, 14:55 </span>
-
Gerrit Code Review pushed patch set 3 for master to change 59156 <span data-processor="relativetime" data-value="2018-12-14T15:00:30+00:00" > 12/14/18, 15:00 </span>
-
Gerrit Code Review pushed patch set 4 for master to change 59156 <span data-processor="relativetime" data-value="2019-02-07T15:21:09+00:00" > 02/07/19, 15:21 </span>
-
Gerrit Code Review pushed patch set 5 for master to change 59156 <span data-processor="relativetime" data-value="2019-02-11T15:35:45+00:00" > 02/11/19, 15:35 </span>
-
Gerrit Code Review pushed patch set 6 for master to change 59156 <span data-processor="relativetime" data-value="2019-02-11T15:37:45+00:00" > 02/11/19, 15:37 </span>
-
Gerrit Code Review pushed patch set 7 for master to change 59156 <span data-processor="relativetime" data-value="2019-02-11T15:59:53+00:00" > 02/11/19, 15:59 </span>
-
Gerrit Code Review pushed patch set 8 for master to change 59156 <span data-processor="relativetime" data-value="2019-02-27T11:44:10+00:00" > 02/27/19, 11:44 </span>
-
Gerrit Code Review pushed patch set 9 for master to change 59156 <span data-processor="relativetime" data-value="2020-04-06T11:37:19+00:00" > 04/06/20, 11:37 </span>
-
Gerrit Code Review pushed patch set 10 for master to change 59156 <span data-processor="relativetime" data-value="2020-05-25T20:46:40+00:00" > 05/25/20, 20:46 </span>
-
Gerrit Code Review pushed patch set 11 for master to change 59156 <span data-processor="relativetime" data-value="2021-11-05T08:38:33+00:00" > 11/05/21, 08:38 </span>
-
Gerrit Code Review pushed patch set 12 for master to change 59156 <span data-processor="relativetime" data-value="2021-11-18T10:45:18+00:00" > 11/18/21, 10:45 </span>
-
Benni Mack changed status
Under ReviewNew <span data-processor="relativetime" data-value="2025-01-27T17:43:20+00:00" > 01/27/25, 17:43 </span> -
Georg Ringer commented and changed status
NewClosed <span data-processor="relativetime" data-value="2025-04-16T09:35:59+00:00" > 04/16/25, 09:35 </span>solved with #100855, see https://github.com/typo3/typo3/commit/1c2b6a80101866451719c99af607192aac82c491
-
Georg Ringer changed Related to #100855 <span data-processor="relativetime" data-value="2025-04-16T09:36:20+00:00" > 04/16/25, 09:36 </span>
I made some tests with a fresh Typo3 8.7.20 instance and can confirm the above issue.
TCA for `pages`:
TCA for `pages_language_overlay`:
Here’s the list used by itemsProcFunc:
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.