B
B
bizzonaru2017-02-09 13:47:05
Yii
bizzonaru, 2017-02-09 13:47:05

Why is the search model not working in the GridView?

There is a gridView that works with a mongoDB collection.
Created a separate model for the collection and a separate search model with model inheritance.
I write settings in gridView, but when selecting a value in the list, after reloading the table, there is no call to the search model, I check the call as Yii::error().

<?= GridView::widget([
                            'dataProvider' => $dataProvider,
                            'filterModel' => $searchModel, 
                            'columns' => [
                                [
                                    'attribute' => 'created_at',
                                    'value' => function(Visitors $model) { 
                                        return  $model->getCreated();  
                                    }                                      
                                ],   
                                [
                                    'attribute' => 'name_bot',
                                    'filter'=> ArrayHelper::map(Bots::getPairs(), 'id', 'name')
                                ],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bizzonaru, 2017-02-09
@bizzonaru

figured out

public function actionIndex()
    {
        $searchModel = new VisitorsSearch();
        
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('index', [
            'dataProvider' => $dataProvider,
            'searchModel' => $searchModel,
        ]);      
        
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question