/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Papka::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
/** * Finds the Papka model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Papka the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Papka::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use backend\models\Papka; /* @var $this yii\web\View */ /* @var $model backend\models\Pages */ /* @var $form yii\widgets\ActiveForm */ //echo var_dump($m); $papki = Papka::find()->all(); $namepap = Papka::findOne($model->id_papka); $p = ''; foreach ($papki as $m) { if ($m->title) { $p .= '<option value="' . $m->id . '">' . $m->title . '</option>'; } } ?> <div class="pages-form"> <?php $form = ActiveForm::begin(); ?> <div class="form-group field-pages-status"> <label for="pages-status" class="control-label">Раздел</label> <select name="Pages[id_papka]" class="form-control" id="pages-status"> <option class="in" value=" <?php echo $namepap['id']; ?>