Hi all.
I have an artist-song (1:N) relation, and I’d like to show the name of the artist in the song list view.
I understood I have to use a code like this in the controller:
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('songs', array(
'pagination'=>array(
'pageSize'=>self::PAGE_SIZE,
),
'criteria'=>array(
'with'=>array('artists'),
),
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
but then? I don’t know what I have to write in the index.php (the list) file.
I used this code
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'title',
'path',
'md5',
array(
'label'=>'Artista',
'name'=>'artists.name',
),
),
)); ?>
in the view.php, and it displays correctly the artist name, but I can’t do the same with the List view.
I found something similar with CGridView, but it uses the “column” attribute, that I can’t use in CListView…
Can anyone give me a hint?
thanks