readonly dropdown

(Linda Anim) #1

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?


(Spyros) #2

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

(Linda Anim) #3

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

(Sharmakiran71) #4


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.



(Linda Anim) #5

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

(Sharmakiran71) #6


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