表单下拉选框及查询下拉选框
form表单
Views中:
<?php echo $form->dropDownList($model,'cate_id',Category::model()->getCategoryList()); ?>
Models中:
public function getCategoryList()
{
$returnArr = $this->findAll();
return CHtml::listData($returnArr, 'cate_id', 'cate_name');
}
查询列表
Models中:
public function getCateName($id)
{
$currCate = $this->findByAttributes(array('cate_id'=>$id));
return $currCate->cate_name;
}
Views中: (admin.php)
//'cate_id',
array('name'=>'cate_id', 'value'=>'Category::model()->getCateName($data->cate_id)', 'filter'=>Category::model()->getCategoryList()),
Meet so Meet.
C plusplus
I-PLUS....