display data of related table in detailview

I have three tables



Student_master (id) is related to student_education (student_id) and class_id is related to class_master(id)

I have relation in Student_master Model named

public function getEducation()


        return $this->hasOne(StudentEducation::className(), ['student_id' => 'id']);


and in st_education Model named

 public function getClass()


        return $this->hasOne(ClassMaster::className(), ['id' => 'class_id']);


I have detail view of Student Master

 <?= DetailView::widget([

        'model' => $model,

        'attributes' => [

            // 'id',





              //  'attribute'=>'photo',

               // 'value'=>$model->photo,

               // 'format' => ['image',['width'=>'200','height'=>'200']],

           // ],



















            // 'to_session',



    ]) ?>

but by this I am getting only class_id



I want to display class name instead of class_id

I dont know how to do this…

I want to display name of class_master table…

Please help


Thanks a lot… it worked…

this helped me a lot, thanks.