Autocomplete in Editor with ID
Autocomplete in Editor with ID
greggreggreg
Posts: 42Questions: 19Answers: 2
I want return a ID from the Editor Autocomplete field on Save, but show the text in search/select.
This works, but of course returns the text, not the ID:
"label": "users_id:",
"name": "usersname",
"type": "autoComplete",
"opts": {
"source": ["abc","dsef","ebc"]
}
},
This does not work, as it does not show me the drop down list:
"label": "users_id:",
"name": "users name",
"type": "autoComplete",
"opts": {
"source": [{"id":1,"test":"abc"},{"id":2,"test":"dsef"},{"id":3,"test":"ebc"}]
}
},
thanks
This discussion has been closed.
Answers
Looks like your
source
object is not the correct format. According to the Autocomplete docs you will want to look at the jQuery autocomplete docs for the source object config. These docs state:I think you will want to swap id/test with label/value.
Kevin
Thanks Kevin, this is close. When I select my choice from the list, the value displays in the text field.
i.e. I select a user, and in the text field I get the ID.
Is that my only option for this? Its like its a Text box, but I guess I am learning I really want a select box?
Do you mean when you submit the whole form?
What is the JSON being returned from the server on save? Does it contain both the id and the label?
I'll confess I find the jQuery UI auto complete library quite hard to use - you frequently have to override its renderer to get it to display the way you want.
Allan