diff --git a/ChangeLog b/ChangeLog index 2f2b4faa7b9ee7ad2ec5169c851b07bdef49f566..c871d62e7bce097e390555f65f5b746439828645 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,7 +20,8 @@ For users: - When creating a contract, sales representative are preset to user. This save 4 clicks. - Can edit several fields in bank transaction line page into one update. - - Creation of contacts from third party page go back to third party. + - Creation of contacts from third party page go back to third party. + - Preselect model if there is only one. This save 2 clicks. - New: Enhance donation module. Add a status "canceled". - New: Add filters on statistics page reports. - New: Usage of Jquery Notify to show result or error messages on action. diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c1f1c17335ea15e8ffb99ceafa79a7885c691a1c..d30f3a70daf40893a1d29b6136704327c5f865e7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3141,7 +3141,7 @@ class Form if (is_array($array)) { - while (list($key, $value) = each ($array)) + foreach($array as $key => $value) { $out.='<option value="'.($value_as_key?$value:$key).'"'; // Si il faut pre-selectionner une valeur diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index a2b71df348cf0ae90b5bec9db2c1441719b4b04f..f719b11f301d80a3dfd6b7eed2a049e044e26d73 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -363,6 +363,11 @@ class FormFile { print '<td align="center" class="formdoc">'; print $langs->trans('Model').' '; + if (is_array($modellist) && sizeof($modellist) == 1) // If there is only one element + { + $arraykeys=array_keys($modellist); + $modelselected=$arraykeys[0]; + } print $html->selectarray('model',$modellist,$modelselected,$showempty,0,0); if (sizeof($cgvlist) > 0) {