Hi ya’ll I’m still getting acquainted with Yii and it’s a bit of a challenge given that I have no prior experience with frameworks and very little with object oriented programming in general. Anyhoo, here’s the first roadblock I have come across. Here’s hoping someone can provide a little guidance, maybe just a nudge in the right direction.
Using CGridView, pulling data from several models is no problem:
// some code in a model ('Company'):
$criteria=new CDbCriteria;
$criteria->compare('name',$this->name,true);
$criteria->compare('industry',$this->industry);
$criteria->with = array( 'relationship' );
// relationship is a relation with another model
$dataProvider = new CActiveDataProvider(
get_class($this), array('criteria'=>$criteria));
// and then in the view:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
array('name'=>'id', 'visible'=>false),
'name',
'industry',
'website',
'relationship.status',
array( 'class'=>'CButtonColumn' )
),
// 'filter'=>$model
));
But suppose I want to provide filters for fields from more than one model. The ‘filter’ argument only takes a CModel.
See what I mean? What would you recommend as the best way to attack this?