Bug #87472

PHP warning with checkboxes and l10n_display=defaultAsReadonly

Added by Dmitry Dulepov 5 months ago.

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

0%

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

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

History

#1 Updated by Michael Stopp 5 months ago

  • Related to Bug #84997: Localized records with rendertype selectCheckBox + defaultAsReadonly generate PHP warnings added

Also available in: Atom PDF