php - Yii Model CGridView including column with Yii-User Profile Field data -


i'm looking enable search criteria in model related module's model. here's example explain mean:

  • i have 'product' model contains 'user_id'.
  • in yii-user created custom profile field called 'brand'.
  • i have cgridview (with search/filter functionality) in product model's index view lists products.
  • i want add 'brand' profile field (which custom profile field made yii-user) cgridview columns allowing people filter , search grid view 'brand'.

i added following code product model relations:

public function relations() {             yii::import('application.modules.user.models.*');     yii::app()->getmodule('user');     return array(         'user' => array(self::belongs_to, 'users', 'user_id'),     ); } 

and adding product model's search criteria:

$criteria->compare('user.brand', $this->user->profile->brand, true); 

this yields no positive results.

i'm not sure if i'm going right direction here. know how this?

why put below lines in 'relations()' function?

yii::import('application.modules.user.models.*'); yii::app()->getmodule('user'); 

you need put 'brand' how public or private attribute on 'product' model. attribute not persistent, use filter form value.

then use this:

$criteria->compare('user.brand', $this->brand, false); 

and possible need put 'brand' attribute on 'rules()', on array() 'on'=>'search'.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -