I have 2 database that includes countries the other one includes cities. When I want to add new city. I can see the countries that in dropdown menu that I added. However, When I want to list city and the country it belongs to, I can see the id of the country instead of country name.How can I see the name of country in the list. this is my controller:
public function actionIndex()
{
$this->view->title = 'Şehirler';
$countries= ArrayHelper::map(AdrCountry::find()->all(),'id','name');
$cities = AdrCity::find()->all();
return $this->render('index', [
'cities' => $cities,
'countries' => $countries
]);
}
This the view file(imdex.php)
<?php foreach ($cities as $city): ?>
<tr>
<td><input type="checkbox" name="delete[]" value="<?= $city->id?>"></td>
<td><a href="<?= Url::to(['city/update', 'id' => $city->id]) ?>"><?= $city->name ?></a></td>
<td><?= $city->adr_country_id ?></td>
</tr>
<?php endforeach; ?>