Yii Framework Forum: CGridView makes CHtml::encode() crash - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CGridView makes CHtml::encode() crash CHtml.php(66) htmlspecialchars() expects parameter 1 to be string, ar Rate Topic: -----

#1 User is offline   razwiss 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-June 10

Posted 03 June 2010 - 11:03 AM

Hi there,

I'm building a view in order for people to see the items on my website, using a CGridView. I've been using the blog tutorial and it's source code in order to make it. To code is nearly copy pasted.

However, this results in this error

Quote

htmlspecialchars() expects parameter 1 to be string, array given

Quote

C:\wamp\www\yii-1.1.2.r2086\web\helpers\CHtml.php(66)

public static function encode($text)
00065:     {
00066:         return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset);
00067:     }


The only thing that I've changed is the columns (in order to fit my DB) and I removed the buttons column. I've commented the only place where I use Chtml::Encode(), but the error persists. I tried with the buttons column too. Here's the source involved into this.

Item-> getURL function
public function getUrl()
    {
       return Yii::app()->createUrl('consulter/view',array(
           'ITE_Id'=>$this->ITE_Id,
           'ITE_Name'=>$this->ITE_Name,
       ));
    }


Controller action
public function actionConsulter()
    {
        $model=new Item('search');
        if(isset($_GET['Item']))
                $model->attributes=$_GET['Item'];
        $this->render('consulter',array(
                'model'=>$model,
        ));
    }


the actual CGridView in my view

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array(
			'name'=>'ITE_Name',
			'type'=>'raw',
			'value'=>'CHtml::link(CHtml::encode($data->ITE_Name), $data->url)'
		),
		array(
			'name'=>'ITE_Description',
			'type'=>'raw',
			'filter'=>false,
		),
		array(
			'name'=>'Category_CAT_Id',
			'value'=>'Category::model()->getAllCategories()',
			'filter'=>false,
		),
		array(
			'name'=>'ITE_Selling',
			'type'=>'boolean',
			'filter'=>false,
		),
	),
));
?>


I Hope you guys can see the light in this problem, because I can't figure what it is. Thanks.
0

#2 User is offline   razwiss 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-June 10

Posted 03 June 2010 - 11:56 AM

Nevermind, the problem is

'value'=>'Category::model()->getAllCategories()'

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users