Fix troubles in select_language when selected is array

This commit is contained in:
Laurent Destailleur 2022-01-20 19:01:04 +01:00
parent d9b0af616e
commit 050b531403

View File

@ -73,9 +73,10 @@ class FormAdmin
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly); $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
// If the language to select is not inside the list of available language and empty value is not available, we must find // If empty value is not allowed and the language to select is not inside the list of available language and we must find
// an alternative as the language code to pre-select (to avoid to have first element in list pre-selected). // an alternative of the language code to pre-select (to avoid to have first element in list pre-selected).
if ($selected && !array_key_exists($selected, $langs_available) && empty($showempty)) { if ($selected && empty($showempty)) {
if (!is_array($selected) && !array_key_exists($selected, $langs_available)) {
$tmparray = explode('_', $selected); $tmparray = explode('_', $selected);
if (!empty($tmparray[1])) { if (!empty($tmparray[1])) {
$selected = getLanguageCodeFromCountryCode($tmparray[1]); $selected = getLanguageCodeFromCountryCode($tmparray[1]);
@ -83,6 +84,9 @@ class FormAdmin
if (empty($selected)) { if (empty($selected)) {
$selected = $langs->defaultlang; $selected = $langs->defaultlang;
} }
} else {
// If the preselected value is an array, we do not try to find alternative to preselect
}
} }
$out = ''; $out = '';