Answer the question
In order to leave comments, you need to log in
Yii2. CRUD. How to display a list given a parameter?
Good day!
Everything is generated using Gii.
public function actionIndex()
{
$searchModel = new UsersSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
Answer the question
In order to leave comments, you need to log in
Goodnight.
Try this:
This is one of the options.
You can set this parameter in the search model when you form the $dataProvider.
If the search for the GridView is not needed, then this:
public function actionIndex()
{
$query = User::find()->andWhere(['>', 'id', 10]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
return $this->render('index', [
'dataProvider' => $dataProvider,
]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question