Answer the question
In order to leave comments, you need to log in
Why is the error "The "dataProvider" property must be set." thrown?
Unable to display data from db in gridview on layout\cuba
use common\models\Schedule;
use yii\data\ActiveDataProvider;
class LayoutsController extends \yii\web\Controller
{
public $dataProvider;
public function actionCuba()
{
$dataProvider=Schedule::find()->all();
return $this->render('cuba',[
'dataProvider'=>$dataProvider,
]);
}
}
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'week_id',
'value' => 'week.name',
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
Answer the question
In order to leave comments, you need to log in
The all method started returning dataProvider?
https://github.com/yiisoft/yii2/blob/master/docs/g...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question