/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Assettype::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // // $query->andFilterWhere([ // 'recid' => $this->recid, // 'createdate' => $this->createdate, // ]); $query->orFilterWhere(['like', 'typename', $this->globalSearch])->orFilterWhere(['like', 'description', $this->globalSearch]); return $dataProvider; }
<div class="reqdevice-form"> <?php $form = ActiveForm::begin(); ?> <?php $devicetype = new Assettype(); ?> <?php $device = new Assets(); ?> <label>ประเภทอุปกรณ์</label> <?php echo $form->field($model, 'usdef1')->dropDownList(ArrayHelper::map($devicetype->find()->all(), 'recid', 'typename'), ['prompt' => 'เลือกประเภท', 'onchange' => ' $.ajax({ type: "post", url: "index.php?r=reqdevice/showdevice&id=" +$(this).val(), data:{}, //dataType: "json", contentType: "application/json; charset=utf-8", success: function(data) { $("#devicelist").html(data); }, error: function(data){ alert("fail"); } }); ', 'class' => 'form-control'])->label(false); ?>