doubeng9567 2013-03-14 16:04
浏览 27
已采纳

Yii定制了CGridView undefined常量

I am new to Yii, I have the follwing code, 'columns'=>array( 'id', 'name', 'email', array( 'name' => 'deleted', 'value' => $model->deleted == 1 ? 'Yes' : 'No', ), I want to display YES if the deleted field from the database equal 1 or NO if not. and it keeps giving me a PHP notice : Use of undefined constant Yes. Thanks in advance.

EDIT My hole wedgit

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'users-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
    'id',
    'name',
    'email',
    array(
        'name' => 'deleted',


    ),
    /*
    'pass',
    'salt',

    'first',
    'last',
    'phone',
    'attempts',
    'locked',
    'gender',
    'birth',
    'joined',
    'updated',
    'active',
    'reset',
    'permission',
    'appress',
    'deleted',
    */
    array(
        'class'=>'CButtonColumn',
        'template'=>'{view}{ban}',
        'buttons' => array(
            'ban' => array
            (
            'label'=> 'Ban User',
            'url'=>'Yii::app()->createUrl("users/delete", array("id"=>$data->id))' ,

             'click'=>'function(){confirm("Are you sure you want to Ban this ?");}',
            ),
        )
    ),
),

));

  • 写回答

2条回答 默认 最新

  • dongtuo2373 2013-03-14 18:28
    关注

    Try this

    'columns'=>array(
        'id', 
        'name',
        'email',
        array(
            'name' => 'deleted', 
            'value' => '$data->deleted == 1 ? "Yes" : "No"',
         ),
    )
    

    OR the YII way

    'columns'=>array(
            'id', 
            'name',
            'email',
            'deleted:boolean'
        )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境
  • ¥30 关于#java#的问题,请各位专家解答!
  • ¥30 vue+element根据数据循环生成多个table,如何实现最后一列 平均分合并
  • ¥20 pcf8563时钟芯片不启振
  • ¥20 pip2.40更新pip2.43时报错
  • ¥15 换yum源但仍然用不了httpd
  • ¥50 C# 使用DEVMOD设置打印机首选项
  • ¥15 麒麟V10 arm安装gdal