Fix select field in multiselect of languages

This commit is contained in:
Laurent Destailleur 2021-04-12 14:26:09 +02:00
parent eb3438baa7
commit 8fa943edc3
2 changed files with 18 additions and 18 deletions

View File

@ -104,9 +104,9 @@ if ($action == 'add') {
} }
if ($result > 0) { if ($result > 0) {
setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs'); setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
//header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); //exit;
exit; $action = '';
} }
if ($result == 0) { if ($result == 0) {
setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings'); setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');

View File

@ -47,7 +47,7 @@ class FormAdmin
/** /**
* Return html select list with available languages (key='en_US', value='United States' for example) * Return html select list with available languages (key='en_US', value='United States' for example)
* *
* @param string $selected Language pre-selected * @param string|array $selected Language pre-selected. Can be an array if $multiselect is 1.
* @param string $htmlname Name of HTML select * @param string $htmlname Name of HTML select
* @param int $showauto Show 'auto' choice * @param int $showauto Show 'auto' choice
* @param array $filter Array of keys to exclude in list (opposite of $onlykeys) * @param array $filter Array of keys to exclude in list (opposite of $onlykeys)
@ -129,7 +129,7 @@ class FormAdmin
} }
$valuetoshow = picto_from_langcode($key, 'class="saturatemedium"').' '.$valuetoshow; $valuetoshow = picto_from_langcode($key, 'class="saturatemedium"').' '.$valuetoshow;
if ((string) $selected == (string) $keytouse) { if ((is_string($selected) && (string) $selected == (string) $keytouse) || (is_array($selected) && in_array($keytouse, $selected))) {
$out .= '<option value="'.$keytouse.'" selected data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>'; $out .= '<option value="'.$keytouse.'" selected data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>';
} else { } else {
$out .= '<option value="'.$keytouse.'" data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>'; $out .= '<option value="'.$keytouse.'" data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>';