Skip to content

Commit

Permalink
Fixed bug with referenced language array variables
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Aug 10, 2018
1 parent b1c4bb5 commit 5542e04
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/CustomElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,23 +551,32 @@ protected function createDcaItem($fieldPrefix, $fieldName, $fieldConfig, &$palet
}

if (isset($fieldConfig['label'])) {
$fieldConfig['label'] = static::getLabelTranslated($fieldConfig['label']);
$translatedLabel = static::getLabelTranslated($fieldConfig['label']);
// Don’t overwrite referenced variable
unset($fieldConfig['label']);
$fieldConfig['label'] = $translatedLabel;
}

if (
isset($fieldConfig['reference'])
&& is_array($fieldConfig['reference'])
&& count(array_filter($fieldConfig['reference'], 'is_array'))
) {
$fieldConfig['reference'] = array_map(function($label) {
$translatedReference = array_map(function($label) {
return \MadeYourDay\RockSolidCustomElements\CustomElements::getLabelTranslated($label);
}, $fieldConfig['reference']);
// Don’t overwrite referenced variable
unset($fieldConfig['reference']);
$fieldConfig['reference'] = $translatedReference;
}

if ($fieldConfig['inputType'] === 'list') {

if (isset($fieldConfig['elementLabel'])) {
$fieldConfig['elementLabel'] = static::getLabelTranslated($fieldConfig['elementLabel']);
$translatedLabel = static::getLabelTranslated($fieldConfig['elementLabel']);
// Don’t overwrite referenced variable
unset($fieldConfig['elementLabel']);
$fieldConfig['elementLabel'] = $translatedLabel;
}

$fieldConfig['minItems'] = isset($fieldConfig['minItems']) ? (int)$fieldConfig['minItems'] : 0;
Expand Down

0 comments on commit 5542e04

Please sign in to comment.