CGridView Search with relation

Hello,

I am trying to do something that should be easy but I cannot figure out what I am doing wrong.

I have a table article, with an authorid field, and my Article model has a Author relationship :


'author'=>array(

	self::BELONGS_TO, 'User', 'authorid',

),

I’d like to be able, in my CGridView, to search an Article by its author. So I created a virtual field $authorName, which is safe on search. I added the comparision in my search function and the with criteria too :




$criteria->compare('author.name',$this->authorName,true);

$critaria->with=array('author');

But when I tried to search by author, I have an exception because the author table is not loaded :

The first sentence says that the request could not be executed.

The problem is that the table is not loaded, and I don’t understand why, as I put it in the with criteria.

I am also doing this somewhere else in my application, and it’s working well there so I have no idea what is wrong here and what am I forgetting !

Thanks !

Does adding


$criteria->together = true;

help?

If not, can you post your full Author model?

I just found out my problem… It’s a typo !


$critaria->with=array('author');

I wrote $critaria instead of $criteria !

I would have thought that it would raise an exception, but it doesn’t :slight_smile:

Anyway, sorry to bother you with that kind of problem :D

Thanks !