form View and activeDropDownList

in form create i’ve to do this dropdownlist and great work for me

<?php echo CHtml::activeDropDownList($model, ‘id_item’, CHtml::listData(Item::model()->findAll(), ‘id’, ‘item’)); ?>

the problem is ?

in form view

so how can we past the data from dropdownlist to display the ‘item’

hello, if i get u right,

what you have done is echoing the activeDropDownList in your model Form(CFormModel)

while it is suppose to be echoed in the view script inside the view folder.

try to use the demos examples that is packaged with the installation

e.g blog which is in ..//yii/demos/blog

can we build query in form view because i want to display related field.

I think, what you need is a javascript. You use javascript to get the value of your dropdownlist, and then put it into another div or other element. It would look something like this:


 //the javascript that doing the jobs

 $script = "function showItemValue(){

              document.getElementById('xxx').innerHTML = document.getElementById('the_drop_down_list_id_name').value;


//put the script to the view

Yii::app()->clientScript->registerScript('js1', $script, CClientScript::POS_END);


<?php echo CHtml::activeDropDownList($model, 'id_item', CHtml::listData(Item::model()->findAll(), 'id', 'item'), array('onchange'=>'showItemValue()')); ?>

<div id='xxx'></div>

no, i’ve mean i want to display data lookup field in view mode.

do you’ve any idea?