dropDownList selected option


(Janusz2929) #1

How I can set "selected" option in dropDownList?


$form->dropDownList($model,'sex',array('1'=>'men','2'=>'women'));

Like that:


<select name="sex">

<option value="1">men</option>

<option value="2" selected="selected">women</option>


(Live Webscore) #2

Try this:


$form->dropDownList($model,'sex',array('1'=>'men','2'=>'women'), array('options' => array('2'=>array('selected'=>true))));

For more info on htmlOptions visit this page http://www.yiiframework.com/doc/api/CHtml#activeDropDownList-detail


(Charles Eapen) #3

bettor , u r a life saver. Thank you very much.


(Anand Neema2008) #4

Thanks bettor …it helps for me…:slight_smile:


(Janis Janovskis) #5

Thanks helped me too


(Qrooel) #6

Works for me, thx. ;]


(Samiloxphp) #7

[b] bettor

[/b]

Thanks Work For me too V


(Bilimarsivi) #8

Thanks in advance.


(Kabul Nazret) #9

Thanks =)


(Anhduc Bkhn) #10

Thanks, helped me too.


(Absarhasan786) #11

Thanks for make it working


(Me) #12

Good one. It’s very useful.


(Ayman Sharkawy609) #13

Thanks a lot


(Etelaat Ganjine) #14

Thanks Work For me too B)


(Etelaat Ganjine) #15

ty B)