I have two tables
staff
id
name
attendance
staff_id
attendance
public function getStaff()
{
return $this->hasOne(Staff::className(), ['id' => 'staff_id']);
}
public function getStaffName() {
return $this->staff->name;
}
<?= GridView::widget([
[
'attribute'=>'staff_id',
'value'=>'StaffName',
],
]); ?>
Add this in search model
$query->joinWith(['staff(relation name)']);
And add below code at filter query.
$query->andFilterWhere(['like', 'staff.name', $this->staff_id])
In staff.name
that in staff
is table name.