table
category(id,category...)
content (id, cid, title...)
model
public function relations()
{
return array(
'cate_r'=>array(self::BELONGS_TO, 'Category', 'cid'),
);
}
public function attributeLabels()
{ return array( 'id' => 'ID', 'cid' => 'Cid', 'cate_r'=>'分类',
}
public function rules()
{
array('id, cid, cate_r, title....', 'safe', 'on'=>'search'),
}
view
admin.php
array(
'name' => 'category_name',
'value' => '$data->cate_r->category',
),
_search.php
<?php echo $form->label($model,'cate_r'); ?>
<?php echo $form->textField($model,'cate_r',array('size'=>60, 'maxlength'=>60)); ?>