qstyler
(Kest Bodnya)
June 28, 2011, 7:44pm
1
Hi!
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.
atti
(Atti84it)
June 28, 2011, 10:30pm
2
i think that you need something as
http://www.yiiframework.com/extension/combobox/
hope it helps!
regards!
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.
wendwessen
(Wendwessen)
October 24, 2012, 5:28pm
5
Bianca
(Biancajsen)
October 24, 2012, 6:02pm
6
I think the suggestion of Attilio is a good one and you can store id with it.
gabaoleal
(Gabaoleal)
June 5, 2013, 10:31pm
7
How do i define what will be stored as ID and how can i retrieve it??
Thanks in advance!
deea
(Hizzzer)
September 7, 2014, 2:26pm
8
You can use select options
'city_id' => array(
'type'=>'zii.widgets.jui.CJuiAutoComplete',
'source'=>Yii::app()->createUrl('ajax/autocomplete'),
'options'=>array(
'select'=>'js:function(event, ui) {
$("#hidden_city_id").val(ui.item.id);
return true;
}',
),
),
Don`t forget create hidden filed
<input id="hidden_city_id" name="Orders[city_id]" type="hidden" />