Struggling to pass a parameter (groupid) to the search form to be included as ‘where’ in the database search.
Its already defined in the model.
I get an error here "Undefined variable search
<?php
//MembersController.php
search(Yii::$app->request->queryParams);
$searchModel = $search->search(['searchModel'=>['groupid'=>$groupid]]);
return $this->render('index', [ 'searchModel'=> $searchModel, 'dataProvider' => $dataProvider, ]);
}
//Members model
public function rules() {
return [ [['groupid'], 'integer'],
//....other variables ];
}
public function attributeLabels() {
return [ 'groupid' => 'Umati Africa Group #.',
//....other variables ];
}
//MembersSearch.php (search model)
public function search($params) {
$query = Members::find();
$dataProvider = new ActiveDataProvider(['query' => $query,]);
if (!$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere([ 'userid' => $this->userid,
'groupid' => $this->groupid, ]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['=', 'groupid', $this->groupid]);
return $dataProvider;
}
Struggling to pass a parameter (groupid) to the search form to be includes as ‘where’ in the database search I get an error here "Undefined variable search