In my View
<?php $searchModel = new AgahiSearch();?>
<?php $form = ActiveForm::begin([
'action'=>['site/search'],
'method'=>'get',
'options' => ['data-pjax' => true ]
]);?>
<?php $catobject = new Category();?>
<?php $a = ArrayHelper::map(Category::find()->where(['parent_id'=>'y'])->All(),'id','name');?>
<?= $form->field($catobject, 'parent_id')->dropDownList($a, [
'id'=>'cat-id',
'prompt'=>' select your group ',
'options' =>['data-pjax' => true ]
]);?>
in my Model
public function search($params)
{
$query = Agahi::find();
$dataProvider = new ActiveDataProvider([
'query' => $query
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andfilterWhere(['like','title', $this->title])
->andFilterWhere(['in','type_id',$this->type_id])
->andFilterWhere(['in','cat_id',$this->cat_id]);
return $dataProvider;
}
in my Controller
public function actionSearch()
{
$searchModel = new AgahiSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$modelCatsite= Category::find()->where(['parent_id'=>'y'])->All();
return $this->render('index', [
'dataProvider' => $dataProvider,
'modelCatsite' => $modelCatsite,
]);
}