#87472PHP warning with checkboxes and l10n_display=defaultAsReadonly
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.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.