Bug #87472
closedPHP warning with checkboxes and l10n_display=defaultAsReadonly
0%
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.
Updated by Michael Stopp almost 6 years ago
- Related to Bug #84997: Localized records with rendertype selectCheckBox + defaultAsReadonly generate PHP warnings added
Updated by Georg Ringer over 4 years ago
- Status changed from New to Closed
closed as duplicate of #84997