Monday 19 September 2016

Yii2 Create Dropdown select options with custom Query

         $gisv = Yii::$app->db->createCommand("SELECT u.id as id, CONCAT_WS(' ',dep.dep_name,des.des_name, name) as name FROM `user` as u inner join mst_department dep on dep.d_id=u.department_id inner join mst_designation des on des.ds_id=u.designation_id  where u.role=3");
                                   
  $geb = $gisv->queryAll();
                                 
    $keuzeData = ArrayHelper::map($geb, 'id', 'name');
                       
              echo $form->field($model, 'employee_id')->dropDownList($keuzeData, ['prompt' => '--Select Employee--'])->label(false);
                                       

No comments:

Post a Comment

Setup VueJS in Laravel

Setup VueJS in Laravel 1. You will need to install javascript dependencies by running the following command on your terminal.      npm i...