R
R
Rustam Akimov2017-10-04 16:22:06
Yii
Rustam Akimov, 2017-10-04 16:22:06

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

2 answer(s)
M
Maxim Fedorov, 2017-10-04
@Inogami

on your topic
yiiframework.ru/forum/viewtopic.php?t=35088

M
Maxim Timofeev, 2017-10-04
@webinar

What is the controller here? You need to view.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question