diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 023982e6a7b..f32c0f4119f 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -8707,7 +8707,7 @@ class Form
}
} else {
$id = (string) $id; // if $id = 0, then $id = '0'
- if ($id != '' && ($id == $key || ($id == 'ifone' && count($array) == 1)) && !$disabled) {
+ if ($id != '' && (($id == (string) $key) || ($id == 'ifone' && count($array) == 1)) && !$disabled) {
$out .= ' selected'; // To preselect a value
}
}