Reading the Autocomplete documentation, I did not find anything talking about the html: true / false option, but talk about the extension jquery.ui.autocomplete.html.js created by Scott Gonzalez .
You should return the data in JSON and use the _renderItem method, see below an example:
Autocomplete.php file
//Retorna categorias
$sqlCategorias = mysqli_query($conn, "SELECT id, nome FROM categorias WHERE nome LIKE '%{$termodeBusca}%' AND status = 1 GROUP BY nome LIMIT 10");
if(mysqli_num_rows($sqlCategorias) != 0){
while($Categorias = mysqli_fetch_array($sqlCategorias)){
$resultado[] = array(
"id" => $Categorias['id'],
"value" => "<b>Categoria</b> {$Categorias['nome']}"
);
}
}
JavaScript
$( "#campo-busca" ).autocomplete({
minLength: 0,
source: 'autocomplete.php',
focus: function( event, ui ) {
$( "#campo-busca" ).val( ui.item.value );
return false;
},
select: function( event, ui ) {
$( "#campo-busca" ).val(ui.item.value);
return false;
}
})
.autocomplete( "instance" )._renderItem = function( ul, item ) {
return $( "<li>" )
.data("item.autocomplete", item)
.append( "<div>"+item.tipo+": " + item.value + "</div>")
.appendTo( ul );
};
See working:
var categorias = [
{
id: 1,
tipo: '<b>Categoria</b>',
value: 'Imóvel'
},
{
id: 2,
tipo: '<b>Categoria</b>',
value: 'Móveis'
},
{
id: 3,
tipo: '<b>Categoria</b>',
value: 'Carros'
},
{
id: 4,
tipo: '<b>Categoria</b>',
value: 'Motos'
}
];
$( "#campo-busca" ).autocomplete({
minLength: 0,
source: categorias,
focus: function( event, ui ) {
$( "#campo-busca" ).val( ui.item.value );
return false;
},
select: function( event, ui ) {
$( "#campo-busca" ).val(ui.item.value);
return false;
}
})
.autocomplete( "instance" )._renderItem = function( ul, item ) {
return $( "<li>" )
.data("item.autocomplete", item)
.append( "<div>"+item.tipo+": "+ item.value + "</div>")
.appendTo( ul );
};
<link href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-3.1.0.js"></script><scriptsrc="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<input type="text" id="campo-busca">