I having a little issue try to access a country dictionary table. There are two tables: Agent and Dictionary; the first table storages a country_id field thats relate to Dictionary with this code block in relations() method:
'dictionaryCountry' => array( self::BELONGS_TO, 'Dictionary', '', 'on' => '`dictionaryCountry`.`type` = \'' . DICTIONARY_TYPE_COUNTRY . '\' And code = t.country_id' ),
I have successfull created the CRUD, accessing the Dictionary table on CDetailView views with:
array( 'name' => 'country', 'value' => ($model->dictionaryCountry->text) ? $model->dictionaryCountry->text: "??", 'sortable' => 'true', 'header' => 'País', ),
But at the moment of accessing thru related tables, like $data->customer->dictionaryCountry->text ($data storages an Invoice CActiveDataProvider) it came with this CDbException:
SQL: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.country_id' in 'where clause'
As I see, the issued SQL command didn’t append the Agent table in the query.
Reviewing pieces of code, it seems necessary to add using with() method at the query (which I have properly added at search() method), but for this issue I don’t know where I have to add it…
Thanks for any clue,