晦涩de咚 2016-01-13 17:14:08 3621次浏览 0条评论 0 0 0
controller:
$model=new CompanyVouchers('search');
        $model->unsetAttributes();  // clear any default values
        if(isset($_GET['CompanyVouchers'])){
            $_GET['CompanyVouchers']['accept']=$_GET['CompanyVouchers']['accept']=='是' ? 1 :($_GET['CompanyVouchers']['accept']== '否' ? 0 : $_GET['CompanyVouchers']['accept']);
            $model->attributes=$_GET['CompanyVouchers'];
        }
        $this->render('index',array(
            'model'=>$model,
            'id'=>$id,
		));
view:
<?php  $this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'company-vouchers-grid',
        'dataProvider'=>$model->search($id),
        'filter'=>$model,
        'columns'=>array(
 'accept'=>array(
                'name'=>'accept',
                'value'=>'$data->accept==1 ? "是" : "否"',
                'filter'=>CHtml::activeTextField($model,'accept',array('value'=>isset($model->accept)?($model->accept=='1' ? "是":($model->accept=='0' ? "否" : $model->accept)):'')),
            ),
),
 )); ?>
model:
$criteria->compare('t.accept',$this->accept,true);//改为模糊查询
    没有找到数据。
您需要登录后才可以评论。登录 | 立即注册