/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TaxonomyCategory::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(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Пример #2
0
 public function getModel($model)
 {
     $items = ['Taxonomy' => Taxonomy::className(), 'TaxonomyCategory' => TaxonomyCategory::className()];
     return ArrayHelper::getItems($items, $model, true);
 }
Пример #3
0
<?php

use yii\helpers\Html;
use source\core\lib\Common;
use source\LuLu;
use source\modules\taxonomy\models\TaxonomyCategory;
/* @var $this yii\web\View */
/* @var $model app\models\Taxonomy */
$category = LuLu::getGetValue('category');
$this->title = '新建分类项';
$category = LuLu::getGetValue('category');
$categoryModel = TaxonomyCategory::findOne(['id' => $category]);
$this->addBreadcrumbs([['分类管理', ['/taxonomy']], [$categoryModel['name'], ['/taxonomy/taxonomy', 'category' => $category]], $this->title]);
?>
<div class="taxonomy-create">

    <?php 
echo $this->render('_form', ['model' => $model, 'category' => $category]);
?>

</div>
 /**
  * Finds the TaxonomyCategory model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return TaxonomyCategory the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TaxonomyCategory::findOne(['id' => $id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }