dataProvider not defined

I’ve been following the tutorial for getting started in yii 2.0 and I have run into a problem that I can’t solve. I’m at the stage where I’m generating code with gii and I’ve run into an error with the dataProvider variable, it isn’t defined, and no matter where I look I can’t seem to find where it’s supposed to be. The error I’m getting is and undefined variable, and from what i can tell this is where it is.

  1. line 23

22 <?= GridView::widget([

23 ‘dataProvider’ => $dataProvider,

24 ‘filterModel’ => $searchModel,

25 ‘columns’ => [

26 [‘class’ => ‘yii\grid\SerialColumn’],

27

28 ‘code’,

29 ‘name’,

30 ‘population’,

31

32 [‘class’ => ‘yii\grid\ActionColumn’],

Hello, could you check your actionIndex in your controller? the dataProvider variable should be returned to avoid such error.

i’ve just been following the tutorial and using gii, im not sure where this dataProvider is supposed to be defined, or where it’s referenced for this

It should be in your Controller under actionIndex function.

If you’re using gii, it should be automatically generated.