1
我一直在試圖從控制器傳遞模型數據的陣列到GridView到GridView,但我得到的錯誤:從controlller將數據傳遞到GridView失敗
The "query" property must be an instance of a class that implements the
QueryInterface e.g. yii\db\Query or its subclasses.
這是控制器代碼:
public function actionAddunits($id){
$countUnits = Unitslocation::find()->where(['officelocationid'=>$id])->count();
if(count($countUnits)>0){
$dataProvider = new ActiveDataProvider([
'query' =>Unitslocation::find()->where(['officelocationid'=>$id])->all()
]);
return $this->render('assignunits', ['dataProvider'=>$dataProvider]);
}else{
return 0;
}
}
的視圖(assignunits.php)
<?php
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
// ...
[
'class' => 'yii\grid\CheckboxColumn',
// you may configure additional properties here
],
],]);
?>
可能是錯誤