Dropdown list with autocomplete


I need a special dropdown widget or some advice on how to create it.

Here’s a background of a story.

I’m having like two Models. One has_many other. And this many is reeeealy many.

There’s no point in rendering regular dropdown list with 1000 or more options in it.

So I need a dropdown list that will allow me to type some text before it suggests me an options list.

But it should pass id in the end.

Like on facebook.

like this one?


i think that you need something as


hope it helps!



That one its not a true dropdownlist, it only as a value field, and what i need is a pair id -> value/label where the id was passed to the database and the value is only to view purposes.

Anyone knows how to do that with a dropdown not a simple textfield.

May be try this


I think the suggestion of Attilio is a good one and you can store id with it.

How do i define what will be stored as ID and how can i retrieve it??

Thanks in advance!

You can use select options

'city_id' => array(




                        'select'=>'js:function(event, ui) {


                            return true;




Don`t forget create hidden filed

<input id="hidden_city_id" name="Orders[city_id]" type="hidden" />