I have a city and voters entity in a one to many relationships.I want to convert the entity field(thousands of records in a dropdown) to a text input so that I can implement
Here a solution to add a field regarding the response given by the Symfony Controller. In success, add fields you want by returning a object. Then, in the select, you can access it by ui.item.fields
$('#mySelector').autocomplete({
source : function(requete, reponse) {
lettre = {
lettre: $('#lettre').val()
};
$.ajax({
url: Routing.generate('chargementSource'),
dataType: 'json',
data : lettre,
success: function (donnee) {
reponse(
$.map(donnee, function (objet) {
return {
value: '' + objet.nom + ' ' + objet.prenom +', '+ objet.adresse +' '+ objet.codepostal +', '+ objet.ville + '',
id: objet.id
}
})
);
}
});
},
select: function (event, ui) {
$('#myId').val(ui.item.id);
//alert(ui.item.id);
//$('#myId').val(ui.elem.value);
return false;
}
});