YII CGridView 错误 [英] YII CGridView error

查看:29
本文介绍了YII CGridView 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

控制器:

public function actionItem($textdata){
        $dataProvider = new CActiveDataProvider('Mytest', array(
            'criteria' => array(
                'condition' => 'type="'.$textdata.'"',
            ),
        ));
$bleble = $textdata;
        $this->render('Item', array(
            'dataProvider' => $dataProvider,
            'bleble' => $bleble,
        ));
    }

查看:

$bleble = $bleble;

$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'sample_id',
    'dataProvider' => $dataProvider,
    'columns' => array(
        array(
                'header' => 'id',
                    'name'   => 'id',
                    'value'  =>'$data->id',
                    'type'   =>'raw',
                    "value"  => function($data){
                        echo "text".$data->id;

                    },
            ),

需要!!:

$bleble = $bleble;

    $this->widget('zii.widgets.grid.CGridView', array(
        'id' => 'sample_id',
        'dataProvider' => $dataProvider,
        'columns' => array(
            array(
                    'header' => 'id',
                        'name'   => 'id',
                        'value'  =>'$data->id',
                        'type'   =>'raw',
                        "value"  => function($data){
                            echo $bleble.$data->id;

                        },
                ),

错误:

PHP 通知未定义的变量:bleble

PHP notice Undefined variable: bleble

需要下载链接的文本,这就是我的控制器($ text)$ text 是我必须写出表格的文本,但当它是变量时不起作用,正常文本有效,例如 echo "text".$data->id;

need to download the text of the link that is how I controller ($ text) $ text is the one I have to write out the table but does not work when it is a variable, normal text works for example echo "text".$data->id;

推荐答案

你可以这样做:

"value" => function($data) use ($bleble){
    return $bleble.$data->id;
}

希望这对你有用

这篇关于YII CGridView 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆