listOptions Problem

I am having problems with the following code:


$zones = Zone::model()->findAllByAttributes(array('state_id' => $_GET['id']));

$list = array('' => 'Select...') + CHtml::listData($zones, 'id', 'zone');

echo CHtml::listOptions('', $list, array());


I use that code for update a dropdown field with jquery when is selected data from the first select tag, and may be rendered the options within the second select tag.

I have tested the same code over Yii 1.0.10 and works fine, but not under 1.1.2… i don’t know why. In addition, i made a test calling the code directly by its controller/action, but always, when i use listOptions method, the navigator throws html error 500 Internal Server Error.

Without calling the function all works fine, even using ver. 1.0.10.

Meanwhile i will use my own custom listOptions function, but i would like to know what i am doing bad or what’s happening.

I hope someone can help me out,


Try this:

$zones = Zone::model()->findAllByAttributes(array('state_id' => $_GET['id']));

$list = CHtml::listData($zones, 'id', 'zone');

echo CHtml::listOptions('', $list, array('empty' => 'Select...'));