Yii Framework Forum: dropDownList selected option - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

dropDownList selected option Rate Topic: -----

#1 User is offline   zbh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 10-September 10

Posted 17 September 2010 - 06:04 AM

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>

0

#2 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 747
  • Joined: 02-February 09

Posted 17 September 2010 - 06:39 AM

*
POPULAR

View Postzbh, on 17 September 2010 - 06:04 AM, said:

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>



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.yiiframew...DownList-detail
14

#3 User is offline   charles07 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 05-February 12

Posted 23 February 2012 - 01:56 AM

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

View Postbettor, on 17 September 2010 - 06:39 AM, said:

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.yiiframew...DownList-detail

1

#4 User is offline   Anand Neema 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 12-May 12

Posted 20 June 2012 - 06:31 AM

Thanks bettor ...it helps for me....:-)
0

#5 User is offline   pasim 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 26-July 12

Posted 26 July 2012 - 10:52 AM

Thanks helped me too
0

#6 User is offline   qrooel 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 27-July 12

Posted 01 August 2012 - 11:41 AM

Works for me, thx. ;]
0

#7 User is offline   samilo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 217
  • Joined: 04-October 12

Posted 08 December 2012 - 04:12 AM


bettor

Thanks Work For me too V
Yii :)
0

#8 User is offline   drxy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 30
  • Joined: 12-September 12

Posted 25 February 2013 - 02:09 AM

View Postbettor, on 17 September 2010 - 06:39 AM, said:

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.yiiframew...DownList-detail


Thanks in advance.
1

#9 User is offline   Kabul Nazret 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-October 12
  • Location:Thailand

Posted 27 February 2013 - 03:40 AM

Thanks =)
0

#10 User is offline   anhduc.bkhn 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 09-September 12

Posted 17 December 2013 - 03:26 AM

Thanks, helped me too.
0

#11 User is offline   Absar A Hasan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 23-November 13
  • Location:Pune, India

Posted 21 February 2014 - 01:47 AM

Thanks for make it working
0

#12 User is offline   RajibKumar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 31-March 14

Posted 05 April 2014 - 01:39 AM

View Postbettor, on 17 September 2010 - 06:39 AM, said:

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.yiiframew...DownList-detail


Good one. It's very useful.
0

#13 User is offline   ayman sharkawy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 26-May 14

Posted 26 May 2014 - 05:45 PM

Thanks a lot
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users