Codxplore.com

Latest news:

New android application Islamic Video has been released. its a free islamic video application for android smartphone. Download now!

Yii load data into select box from database


Add your own defined method in your model class .For Example

public function getMacList() {
        $model = POS_MAC::model()->findAll();
        $data = CHtml::listData($model, 'MID', 'MAC_ADDRESS');
        
        return $data;
}
 
and your html where you want to view the data into select box
 
echo $form->dropDownList($model, 'POS_MAC_MID',$model->getMacList(),array('class'=>'form-control'));
?>
 
here,
1st parameter is your model , 
2nd parameter is database column name or model attribute name
3rd parameter is the method which is defined in your model class
4rth parameter is html option . eg (class,id,.....)
 
thanks
Tags :

Views : 693

Subscribe Us


Follow Us