/**
  * 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;
 }
 /**
  * Finds the Assettype model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Assettype the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Assettype::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #3
0
use backend\models\Assettype;
use backend\models\Assets;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model backend\models\Reqdevice */
/* @var $form yii\widgets\ActiveForm */
?>

<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);