Duda With Has_Many


I have a question with has_many relationship display a GridView or DetailView.

I have the following

public function relations() {

        // NOTE: you may need to adjust the relation name and the related

        // class name for the relations automatically generated below.

        return array(

            'coleIdComuna' => array(self::BELONGS_TO, 'Comuna', 'cole_idComuna'),

            'colegioContactos' => array(self::HAS_MANY, 'ColegioContacto', 'colcon_idColegio'),

            'colegioRs' => array(self::HAS_MANY, 'ColegioRs', 'colrs_idColegio'),

            'colegioIdTipo' => array(self::BELONGS_TO, 'Tipo', 'cole_idTipo'),



To display a belongs_to relationship, I do the following:

In GridView:

array('name' => 'colrs_idColegio', 'value' => '$data->colrsIdColegio->cole_nombre'),

In DetailView:

array('name' => 'cole_idComuna', 'value' => $model->coleIdComuna->COMUNA_NOMBRE),

but I need to display a has_many relationship and I failed :S

Wrong forum - you may get better response by posting it in the Yii 1.x forum.

The way you use relations and AR will change significantly in Yii 2.0.