Answer the question
In order to leave comments, you need to log in
How to implement a similar display of related fields?
There are 3 related tables and 3 models respectively:
Seminar (id, city_id, name, ...);
City (id, region_id, name);
Region (id, name).
In the form you need to display:
seminar.id - seminar.name - city.name - region.name The
city is specified in the Seminar model:
public function getCity()
{
return $this->hasOne(City::className(), ['id' => 'city_id']);
}
<li>
<?=$seminar->date_begin;?>
<?=$seminar->city->name;?>
<?= Yii::$app->formatter->asDate($seminar->date_begin , 'php:d F');?>
<?= Html::encode("{$seminar->title}") ?>
</li>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question