nested dropDownList with optiongroup

Hi folks,

i started to learn yii a few days ago and i’m stuck with the following problem for hours…

I want to generate a dropDownList like

<div class="cars-select">

    <?php echo CHtml::dropDownList('Cars', 'car_id', array(







            'volvo-l90e-radlader'=>'L90E Radlader',


    )); ?>



But i get the data from the Database with following table-structure:

Table Studycourse:

id, coursename, extension_of

1, Law, 0

2, Economics, 0

3, Business Law, 1

4, Macro Economics, 2

My DropDownList without option group is working:

$courseExt = Studycourse::model()->findAll(“extension_of IS NOT NULL”, array(‘order’ => ‘id’));

echo $form->dropDownList($model, ‘studycourse_id’, GxHtml::listDataEx($courseExt));

But how can i populate a dropdownlist with option groups?

It should generate the following html:

<select name="studycourse" id="course">

        <optgroup label="Law">

            <option value="law-business">Business Law</option>


        <optgroup label="Economics">

            <option value="economics-macro">Macro Economics</option>