I apologize, I should be able to do this, but for some reason am totally struggling with this today.
I have a model which includes
public function getItem()
{
return $this->hasOne(LstItems::className(), ['ItemId' => 'ItemId']);
}
In my index view, I have a GridView column like
[
'content' => function($model,$key) {
return Html::button('<i class="glyphicon glyphicon-search"></i>',
[
'class' => 'btn btn-info btn-xs modalButton',
'value'=>Url::to('index.php?r=lst-employees/update').'&id='.$key,
'title'=>'Updating . $model->getItem()->ItemDescription,
]) ;
},
'label' => 'View',
],
in which I am trying to use the model function to return the related attribute value, but I can’t get it functional. No matter what I try, my syntax is always wrong.
What is the proper way to write
$model->getItem()->ItemDescription
So it returns the value of the ItemDescription from the LstItems table which has the same ItemId?