Yii Framework Forum: readonly dropdown - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

readonly dropdown Rate Topic: -----

#1 User is offline   d135ks 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 67
  • Joined: 11-July 11

Posted 13 July 2011 - 09:14 PM

hi all, i wanna ask something, I have a code like this :
<?php echo $form->dropDownList($model,'id_advertiser',CHtml::listData(Advertiser::model()->findAll('deleted IS NULL or deleted <> :deleted',array(':deleted'=>1)), 'id', 'name'),array('empty'=>'--please select one--',[color="#FF0000"]'readonly'=>true[/color])?>


i had put code read only, but it's not working. How to make a dropdownlist readonly?
thanks
1

#2 User is offline   Spyros 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 461
  • Joined: 14-April 09
  • Location:Athens - Greece

Posted 13 July 2011 - 10:55 PM

I don't think that you can make a dropdown readonly.
Yoy can use
"disabled"=>"disabled" 
instead of 
"readonly"=>true


But this won't post the dropdown value.
If you need to pass the dropdown value consider using a disabled dropdown and a hidden field
2

#3 User is offline   d135ks 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 67
  • Joined: 11-July 11

Posted 13 July 2011 - 11:03 PM

thanks for the repply, but it doesn't work for me,if i code like that.
0

#4 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 483
  • Joined: 21-May 11
  • Location:India

Posted 14 July 2011 - 02:38 AM

Hi,
can't understand clearly why you want this type of field.
you can use 'readonly'=>true and your dropdown will darken as readonly field.
..
if you don't want field as to use anywhere and just wanna show it for info you can do.
.
..
Thanks.
Thanks,
Kiran Sharma.
0

#5 User is offline   d135ks 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 67
  • Joined: 11-July 11

Posted 14 July 2011 - 02:43 AM

Thanks kiran, can you make example how to use java script? because i newbie in php,javascript.
0

#6 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 483
  • Joined: 21-May 11
  • Location:India

Posted 30 May 2012 - 04:31 AM

Hi,
this is my code for disable dropdown and it works perfectly,

<?php echo CHtml::activeDropDownList($model,'subscribed_newsletter' , array('1'=>'Subscribed','0'=>'Not subscribed'),array("disabled"=>"disabled")); ?>


Thankx.. :)
Thanks,
Kiran Sharma.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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