GSTAR
(Omzy83)
1
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">
konapaz
(Konapaz)
2
Hi
Did you try this ?
echo $form->dropDownList($model, 'cars', $model->getCarsList(),array('data-cat-id'=>'5'));
konapaz
(Konapaz)
3
GSTAR
(Omzy83)
4
Well that will add the attribute to the SELECT tag - I want to add the attribute to each OPTION tag within the SELECT.
konapaz
(Konapaz)
5