display data of related table in detailview

I have three tables

7020

p.jpg

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',

             'name',

             'do',

             'gender',

            //[

              //  'attribute'=>'photo',

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

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

           // ],

             'contact',

            [

                'attribute'=>'class_id',

                'value'=>$model->education->class_id

            ],

            [

                'attribute'=>'section',

                'value'=>$model->education->section_id

            ],

            [

                'attribute'=>'roll_no',

                'value'=>$model->education->roll_id

            ],

            [

                'attribute'=>'address',

                'value'=>$model->addresses->street_address

            ],

             'from_session',

            // 'to_session',

             'addmission_no',

        ],

    ]) ?>



but by this I am getting only class_id

7019

s.jpg

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




    'value'=>$model->education->class->name,



Thanks a lot… it worked…

this helped me a lot, thanks.