<?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'business-grid', 'dataProvider'=>$dataProvider, 'filter'=> Business::model(), 'columns'=>array( 'business_id', 'name', 'package_id'=> array( 'name' => 'package_id', 'value' => '$data->package->package_title', 'filter'=> CHtml::listData(Packages::model()->findAll(array('order'=>'package_title')), 'package_id', 'package_title') ), 'user_id'=>array( 'name' => 'user_id', 'value' => '$data->user->name', 'filter'=> CHtml::listData(Users::model()->findAll(array('order'=>'firstname')), 'id', 'name') ), 'categories' => array( 'name' => 'categories', 'value' => '$data->returnAllCategories(", ",false);', 'filter'=> CHtml::listData(Categories::model()->findAll(array('order'=>'category')), 'cat_id', 'category') ), 'keywords' => array( 'header' => 'Keywords', 'value' => '$data->returnAllKeywords(", ",false);', ), 'links'=>array( 'header'=>'Manage', 'type'=>'raw', 'value'=>'CHtml::link(CHtml::image(Yii::app()->request->baseUrl."/images/admin/approve.png","Approve"), array("approve","id"=>$data->business_id,"item"=>"business"),array("class"=>"approve-link","title"=>"Approve Business"))." ". CHtml::link(CHtml::image(Yii::app()->request->baseUrl."/images/admin/reject.png","Reject"), array("reject","id"=>$data->business_id,"item"=>"business"),array("class"=>"reject-link","title"=>"Reject Business"))', ), ), ));
生成type下拉框可以这么写:
'type'=>array( 'name' => 'type', 'filter'=>$model->getTypeOptions(), ),'type'=>array( 'name' => 'type', 'filter'=>$model->getTypeOptions(), ),
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。