Hey Guys,
because my work with Yii is my very first experience regarding php I started working through the tutorial given in the guide 2.0. Until now everything worked out very fine, but now I have Problems generating the CRUD code.
The first thing I noticed is, that the code generation doesn’t even work when I follow this picture and insert @app\views\country for View Path. When I leave out the ‘@’ it suddenly works…
But when I try to access the index page after successfully genrating the code I get another error:
PHP Notice – yii\base\ErrorException
Undefined variable: countries
1. in /home/blabla/views/country/index.php at line 7
<?php
use yii\helpers\Html;
use yii\widgets\LinkPager;
?>
<h1>Countries</h1>
<ul>
<?php foreach ($countries as $country): ?>
<li>
<?= Html::encode("{$country->name} ({$country->code})") ?>:
<?= $country->population ?>
</li>
<?php endforeach; ?>
</ul>
<?= LinkPager::widget(['pagination' => $pagination]) ?>
Line 7 means the head of the foreach-loop.
I hope you can help me, thanks