let’s assume I have Gallery model which has following relation:
'photos' => array(self::HAS_MANY, 'Photo', 'gallery_id');
now, when displaying single gallery page I’d like to retrieve CActiveDataProvider for $gallery->photos, so I can pass it to CListView.
Is that possible anyhow?
Just an example, customize it as you like:
foreach($photos as $attribute)
Sounds like a simple task that is very similar to the one shown in the blog tutorial. there, there are blog post and you want to show the post related comments. Check out how its done here: http://www.yiiframework.com/doc/blog/1.1/en/comment.create
guys, I know the way you showed, it’s obvious and trivial.
What I’m looking for is how to feed CActiveDataProvider with data from “related” field.
What I mean is:
I define relation
I create CActiveDataProvider for that
writing findAll(‘galler_id = :gid’, …) is in fact redefinition of relation, which is against DRY [Don’t Repeat Yourself]