Filter REST with relationships

I try to filter query results with relationship. I have Comment and Post models with hasOne relation (Comment belongs to Post, and Post hasMany Comments).

With request I would like show all comments that belongs to post with id=10.
In comment controller I use IndexAction class to define actionIndex with dataFilter defined yii\data\ActiveDataFilter class.

I try to use request

but is converted to post_id and in SQL I have error, that post_id field is not defined.

How can I use filter by related table?

Big thanks for help!

For others…
I used attributeMap properties.

Hi Qwerty,

I’m also having this issue. Would you be able to provide more information about your solution please?