Yii Cheat Sheet: Filtering by Related Models in a CGridView

Yii Cheat Sheet: Filtering by Related Models in a CGridView

Last updated:

This is what you have to do to filter by other properties than the ones your model has:

  • Make new "property" (required)

  • mark as "safe" in 'on'=>'search' scenario in rules method (required)

  • set name in attributeLabels method (optional)

  • add condition with "with" and "together" in search function (required)

  • set "name" in "columns" as the "property" name(required)

Based on this EXCELLENT post by Piotr Osipa.

Dialogue & Discussion