Issue Bug Closed

#86985itemsProcFunc for select->selectSingle shows key instead of label in page translation

NGUYEN Duc Quan 11/23/18, 14:20 updated 04/16/25, 09:35

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