Project

General

Profile

Actions

Bug #87472

closed

PHP warning with checkboxes and l10n_display=defaultAsReadonly

Added by Dmitry Dulepov almost 6 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2019-01-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If a checkbox field is defined with 'l10n_display' => 'defaultAsReadonly', translations will show a PHP warning:

PHP Warning: array_flip() expects parameter 1 to be array, string given in /home/app/web/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php line 82

This code is responsible:

typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php

        $parameterArray['itemFormElValue'] = $row[$fieldName];
        // Set field to read-only if configured for translated records to show default language content as readonly
        if ($parameterArray['fieldConf']['l10n_display']
            && GeneralUtility::inList($parameterArray['fieldConf']['l10n_display'], 'defaultAsReadonly')
            && $isOverlay
        ) {
            $parameterArray['fieldConf']['config']['readOnly'] = true;
            $parameterArray['itemFormElValue'] = $this->data['defaultLanguageRow'][$fieldName];
        }

On a first line $row[$fieldName] is an array (preprocessed earlier). When it is replaced by a default language value, it is replaced by a string. Later, in web/typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php:

        $parameterArray = $this->data['parameterArray'];
        $config = $parameterArray['fieldConf']['config'];
        $disabled = !empty($config['readOnly']);

        $selItems = $config['items'];
        if (!empty($selItems)) {
            // Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
            $itemArray = array_flip($parameterArray['itemFormElValue']);

This is where the exception happens.

Solution: do not set the value, use the existing value because it is already set.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #84997: Localized records with rendertype selectCheckBox + defaultAsReadonly generate PHP warningsClosed2018-05-14

Actions
Actions

Also available in: Atom PDF