I am using in my form a dropdown list with CHtml::listData in the following way:-
<div class="row"> <?php echo $form->labelEx($model,'des_res_id'); ?> <?php echo $form->dropDownList($model, 'des_res_id', CHtml::listData($data, 'id','ClientId'), array('empty'=>'None','id'=>'res')); ?> <?php echo $form->error($model,'des_res_id'); ?><div id='info' style="display: inline;"></div> </div>
In the above code, I am using ‘id’ as the value and ‘ClientId’ as text for the dropDownList and $data is the list of model objects from which these values come. Once I select the value, I would like to display in the div (id=‘info’) some text which is actually another attribute (name) of the model object and this information is available in $data. I can write a function in the controller which can be called to display this info in the required div by using jquery and $("#info").html. But I guess there must be a shorter way of doing since this information is readily available in the list of model objects for the dropdownlist.
Can anyone tell me how to do it?