/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = LgJenisKendaraan::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(['kode' => $this->kode]); $query->andFilterWhere(['like', 'jenis_kendaraan', $this->jenis_kendaraan]); return $dataProvider; }
protected function findModelJenisKendaraan($id) { if (($model = LgJenisKendaraan::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="lg-kendaraan-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'nomor_polisi')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'tahun_pembelian')->textInput(); ?> <?php echo $form->field($model, 'jenis_transportasi')->dropdownList(LgJenisKendaraan::find()->select(['jenis_kendaraan', 'kode'])->indexBy('kode')->column(), ['prompt' => 'Select Jenis Kendaraan']); ?> <?php echo $form->field($model, 'penanggung_jawab')->dropdownList(Pegawai::find()->select(['nama_lengkap', 'id_pegawai'])->indexBy('id_pegawai')->column(), ['prompt' => 'Select Penanggung Jawab']); ?> <?php echo $form->field($model, 'bahan_bakar')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'berat_muatan')->textInput(); ?> <div class="form-group">