dixonsatit / yii2-toggle-column

Toggle column update in gridview
Apache License 2.0
19 stars 7 forks source link

Unknown Method was thrown ! #3

Open deshario opened 6 years ago

deshario commented 6 years ago

I am not sure that what's missing ... how to fix it

Calling unknown method: app\models\UserSearch::getItemFilter()

Model

 public function getToggleItems()
    {
        // custom array for toggle update
        return  [
            'on' => ['value'=>1, 'label'=>'Publish'],
            'off' => ['value'=>0, 'label'=>'Panding'],
        ];
    }

Gridview

          [
                'attribute'=>'status',
                'class'=>'\dixonstarter\togglecolumn\ToggleColumn',
                'options'=>['style'=>'width:50px;'],
                'linkTemplateOn'=>'<a class="toggle-column" data-pjax="0" href="{url}">{label}</a>',
                'linkTemplateOff'=>'<a class="toggle-column" data-pjax="0" href="{url}">{label}</a>'
            ],

Controller

   'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                    'toggle-update'=>[
                        'class'=>'\dixonstarter\togglecolumn\actions\ToggleAction',
                        'modelClass'=>User::className()
                    ]
                ],
            ],

unknow

zhandos38 commented 5 years ago

Just in case. for others. you forgot to add "use \dixonstarter\togglecolumn\ToggleActionTrait;" before function getToggleItems()