Answer the question
In order to leave comments, you need to log in
How to manage GET request in Yii2?
I have an action, when I make a request through a form, it redirects to itself and my url multiplies, there are a lot of identical getas, how can I clear them or can I get rid of this
public function actionIndex()
{
$request = Yii::$app->request;
$get = $request->get('Persona');
$name = $get['name'];
if(isset($name)){
$query = Persona::find()->where(['like','name', $name]);
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count()]);
$persona = $query->offset($pages->offset)
->limit($pages->limit)
->all();
}else{
$query = Persona::find();
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count()]);
$persona = $query->offset($pages->offset)
->limit($pages->limit)
->all();
}
$model = new PersonaSearch();
return $this->render('index',[
'persona' => $persona,
'model' => $model,
'pages' => $pages,
]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question