/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TaxonomyVocabulary::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
<?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel app\models\TaxonomyItemsSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $in = Yii::$app->request->get('TaxonomyItemsSearch'); if (isset($in['vid']) && $in['vid']) { $_model = \backend\models\TaxonomyVocabulary::findOne($in['vid']); $this->title = $_model->name; } else { $this->title = 'Vocabulary Items'; } $this->params['breadcrumbs'][] = ['label' => 'Taxonomy Vocabularies', 'url' => '/admin/taxonomy-vocabulary']; $this->params['breadcrumbs'][] = $this->title; ?> <div class="taxonomy-items-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create', ['create?TaxonomyItems[vid]=' . $in['vid']], ['class' => 'btn btn-primary']); ?>
<?php use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model app\models\TaxonomyItems */ $this->title = 'Update Taxonomy Items: ' . ' ' . $model->name; $this->params['breadcrumbs'][] = ['label' => 'Taxonomy Vocabularies', 'url' => '/admin/taxonomy-vocabulary']; $_model = \backend\models\TaxonomyVocabulary::findOne($model->vid); $this->params['breadcrumbs'][] = ['label' => $_model->name, 'url' => '/admin/taxonomy-items?TaxonomyItemsSearch[vid]=' . $model->vid]; $this->params['breadcrumbs'][] = $model->name; ?> <div class="taxonomy-items-update"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo $this->render('_form', ['model' => $model]); ?> </div>
/** * Finds the TaxonomyVocabulary model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TaxonomyVocabulary the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TaxonomyVocabulary::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }