Conditional dropdown in a _form


In a _form.php view I have two drop-downs.

I created both with the proper dropDownList like this:

echo $form->dropDownList($model,'tab1', CHtml::listData(Tab1::model()->findAll(), 'codice', 'codiceDescrizione'));

The problem is that the second drop-down content should be conditioned on what the user chooses on the first, which means Tab1->onchange ==> load Tab2.

I know how to do with plain js+php, but what’s the best way to do it in yii?

Obviously, on update both fields should be populated automatically from the model.


Hello. You can see here:

Creating a dependent dropdown

sometimes i’m really too lazy :(

thankyou very much