/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Kategori::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'isim', $this->isim]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getKategori() { return $this->hasOne(Kategori::className(), ['id' => 'kategori_id']); }
/** * Finds the Kategori model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Kategori the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Kategori::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php echo $form->field($model, 'kitap_adi')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'yazar_adi')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'yayinevi')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'kategori_id')->dropDownList(ArrayHelper::map(Kategori::find()->all(), 'id', 'isim'), ['prompt' => 'Kategori Seçiniz..']); ?> <?php echo $form->field($model, 'sayfa_sayisi')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php