Change atribute for related model in GridView and DetailView

Hi Everyone!

I’ve followed this tutorial and everything went perfect. However, I was wondering how to change the attribute label for the related model (Author in the example).

I tried adding this to PostSearch with no success:




public function attributeLabels()

{

   return array_merge(parent::attributeLabels(), ['area.name' => 'Area Name']);

}



Thanks!

did you try same in class Post?

Yes, if I add area.name to the Post attribute labels it works. However I’m not sure if that is tidy enough :lol:

you should see this display data of related table in detailview