Codxplore.com

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


in top of your model import array helper class

use yii\helpers\ArrayHelper;

in the model section we can populate the data this way.

public function getServices()
    {
        $model = Services::find()->all();
        $listData=ArrayHelper::map($model,'service_id','name_en');
        return $listData;
    }

in the view section we need to use like that

   
    echo $form->field($model, 'services')->dropDownList($model->getServices(),

   ['class' => 'form-control', 'multiple' => true]);
?>

Tags :

Views : 3928

Subscribe Us


Follow Us