Dataprovider With Complicated Relations

Hello. I’ve got this kind of problem:

I’ve got 3 db tables (and models) and defined relations inside this models:




Obserwacje(id, id_gatunku); relacje:'idGatunku' => array(self::BELONGS_TO, 'Gatunki', 'id_gatunku'),

Gatunki(id,nazwa_gatunku,id_grupy ); relacje:'nazwaGrupy' => array(self::BELONGS_TO, 'GrupyGatunkow', 'id_grupy'),

GrupyGatunkow(id, nazwa) (bez relacji)



Additional, in "Obserwacje" model

  1. i have defined $public grupa_szukaj

  2. in search() function i added this $criteria:




$public grupa_szukaj;


$criteria->with = array('idGatunku');   



My question is: how can I make a search in view of Obserwacje based on the field name of the model GrupyGatunkow (i know that i have to define $criteria->compare in search() function in Obserwacje model, but this defined by me doesn’t work:




$criteria->compare('idGatunku.nazwaGrupy.nazwa', $this->grupa_szukaj, true );  

$criteria->compare('idGatunku->nazwaGrupy->nazwa', $this->grupa_szukaj, true ); 



p.s. this is my code from Obserwacje view:




<?php $this->widget('bootstrap.widgets.TbGridView',array( 

	'dataProvider'=>$model->search(),

	'columns'=>array(       

                array(

                    'name'=>'grupa_szukaj',

                    'value'=>'$data->idGatunku->nazwaGrupy->nazwa'), 

		array(

			'class'=>'bootstrap.widgets.TbButtonColumn',

		),

	),

)); ?>



Thanks for help

Greetings

Tom

Does this help?

link

Thanks Stageline, it works well :) Solved :)