Specify Additional Attributes For Dropdownlist Options

How can I create every dropdownlist option to have this markup:


<option value="1" data-cat-id="5" data-type="Cars">Ford Fiesta</option>


<?php echo $form->dropDownList($model, 'cars', $model->getCarsList()); ?>


// $model->getCarsList() returns CHtml::listData();



Furthermore, is it possible to customise the OPTGROUP tag (generated from listData) to have this markup:


<optgroup label="Cars" data-cat-id="5">

Hi

Did you try this ?


echo $form->dropDownList($model, 'cars', $model->getCarsList(),array('data-cat-id'=>'5'));

Also fo the second issue check this

http://www.yiiframework.com/forum/index.php/topic/31156-grouped-drop-down-list/page__p__150064__hl__DropDownLi+t+Group#entry150064

Well that will add the attribute to the SELECT tag - I want to add the attribute to each OPTION tag within the SELECT.

I had a similar issue, check this

http://www.yiiframework.com/forum/index.php/topic/50703-chtmldropdownlist-specific-option/