dependent dropdown


foreach($data as $value=>$name)


    echo CHtml::tag('option',



plzzz anyone explain me from where we get $data=CHtml::listData($data,‘id’,‘name’); this line i didnt understand

From the code above you are trying to achieve a drop-down list in yii. It would have been easier if you went with a full yii implementation. But either way let’s me just explain the code.

CHtml::listData() this creates an array of options from the $data parameter(this comes from querying model data) passed, id is the value that will be passed in option as value and name will be the display name seen on the drop-down.


CHtml::dropDownList($model,‘id’, CHtml::listData(Company::model->findAll(), ‘id’, ‘companyName’))