在Gridview返回错误中打印图像

时间:2013-11-23 09:56:30

标签: gridview yii

我正在尝试在gridview中打印图像,但我有以下错误,如果我在视图页面中打印所有工作,所以 怎么了 ? enter image description here 查看代码:

        <?php
        $assetsDir = Helper::UPLOAD_DOMAIN_URL . Helper::PRODUCT_UPLOAD_FOLDER . Helper::Countries; 
    // return http://localhost/upload/ssofiles/countries/
        ?>

        $this->widget('application.components.GridView.BSGridView', array(
                'id' => 'countries-grid',
                'dataProvider' => $model->search(),
                'filter' => $model,
                'columns' => array(
                'co_id',
                'country',
                'country_e',
                'country_f',

                'code',
                array(
                        // 'value'=>'Yii::app()->request->baseUrl."/upload/".$data->image'
                        'name' => 'image',
                        'type' => 'html',
                        'value' => '(!empty($data->image))?CHtml::image($assetsDir$data->image),"",array("style"=>"width:25px;height:25px;")):"no image"',

                ),
...............        

 ?>

2 个答案:

答案 0 :(得分:0)

'code',
            array(
                    // 'value'=>'Yii::app()->request->baseUrl."/upload/".$data->image'
                    'name' => 'image',
                    'type' => 'html',
                    'value' => '(!empty($data->image))?CHtml::image($assetsDir$data->image),"",array("style"=>"width:25px;height:25px;")):"no image"',// typo

            ),

...............

更改为

'code',
            array(
                    // 'value'=>'Yii::app()->request->baseUrl."/upload/".$data->image'
                    'name' => 'image',
                    'type' => 'html',
                    'value' => '!empty($data->image) ? CHtml::image($assetsDir . $data->image,"",array("style"=>"width:25px;height:25px;")) : "no image"',

            ),

...............

答案 1 :(得分:0)

我通过直接在我的代码中通过调用路径修复它:

array('name' =>'image','filter'=>false, 'value' => 'CHtml::link(
            CHtml::image(Helper::UPLOAD_DOMAIN_URL . Helper::PRODUCT_UPLOAD_FOLDER . Helper::Countries . $data->image, $data->image, array("width"=>32,"height"=>32)),
            Helper::UPLOAD_DOMAIN_URL . Helper::PRODUCT_UPLOAD_FOLDER . Helper::Countries . $data->image,array("id"=>"add"))',
            'type' => 'raw',
        ),