hi, how to sort the data let’s say I wanna put the “Others” at the bottom of the drop down list of subcategory.
here’s the sample data of the subcategory table
subid subcat
76 women bags
77 woman accessories
78 men apparels
79 women shoes & heels
80 men accessories
81 woman apparels
82 others
143 men shoes
and here’s the code that calls the subcategory
$subcatOps = array();
if (!empty($selectedMainCategory)) {
$subCat = subcat::model()->findAll('MAINCATID =:mainCatId', array('mainCatId' => $selectedMainCategory));
$subCatOps = CHtml::listdata($subCat, 'SUBID', 'SUBCAT');
}
echo $form->dropDownList($model, 'SUBID',$subCatOps, array('empty' => ' Select ', 'class' => 'subSelect', 'style' => ''));
echo $form->error($model, 'SUBID');
here’s what i did
$subcatOps = array();
if (!empty($selectedMainCategory)) {
$others = '';
foreach($subCatOps as $key => $item) {
if($item === "Others"){
$others = $subCatOps[$key];
unset($subCatOps[$key]);
}
}
$subCatOps[] .= $others;
}
echo $form->dropDownList($model, 'SUBID',$subCatOps, array('empty' => ' Select ', 'class' => 'subSelect', 'style' => ''));
echo $form->error($model, 'SUBID');
but nothing happens …it didn’t reflect in the sub category dropdown , what to do?
by the way , the SUBID should not change because it is in the db table…i suspect that’s the reason
why it doesn’t reflect in the sub category dropdown