readonly dropdown

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?


I don’t think that you can make a dropdown readonly.

Yoy can use


instead of 


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

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


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 kiran, can you make example how to use java script? because i newbie in php,javascript.


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… :)