Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Category::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['left' => SORT_ASC]]]);
     $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(['id' => $this->id, 'left' => $this->left, 'right' => $this->right, 'level' => $this->level]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Finds the Category model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Category the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     return Category::findOne($id);
     //        if (($model = Category::findOne($id)) !== null) {
     //            return $model;
     //        } else {
     //            throw new NotFoundHttpException('The requested page does not exist.');
     //        }
 }
Example #3
0
 public function getCategory()
 {
     return $this->hasOne(Category::className(), ['id' => 'category_id']);
 }
Example #4
0
/* @var $model app\modules\post\models\PostSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="search-form">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'post', 'options' => ['class' => 'form-inline']]);
?>
    
    <?php 
echo $form->field($model, 'title', ['template' => '{input}', 'inputOptions' => ['placeholder' => $model->getAttributeLabel('title')]])->label(false);
?>
    
    <?php 
echo $form->field($model, 'category_id', ['template' => '{input}'])->dropDownList(ArrayHelper::map(Category::find()->orderBy('left')->all(), 'id', 'fulltitle'), ['prompt' => 'Tất cả danh mục'])->label(false);
?>
    
    <?php 
echo $form->field($model, 'active', ['template' => '{input}'])->dropDownList([0 => 'Ngừng hoạt động', 1 => 'Hoạt động'], ['prompt' => 'Tất cả trạng thái'])->label(false);
?>

    <?php 
// echo $form->field($model, 'meta_title')
?>

    <?php 
// echo $form->field($model, 'meta_desciption')
?>

    <?php