Tbgridview And Render Customized/complex Datacolumns

Hi All,

I am getting the following error:

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

when trying to do customized/complex datacolumns.

I have the following code:


<?php $this->widget('ext.bootstrap.widgets.TbGridView', array(

    'id'=>'rabbitshow-grid',

    'type'=>'striped bordered condensed',

    'dataProvider'=>$model->search(),

    'filter'=>$model,

    'template'=>"{items}",

    'columns'=>array(

        array('name'=>'show_name', 'header'=>'Show'),

        array('name'=>'show_date', 'header'=>'Date'),

        array('name'=>'judge', 'header'=>'Judge'),

        array('name'=>'StatusText', 'header'=>'Status'),

        array(

            'name'=>'entries',

            'type'=>'raw', //because of using html-code from the rendered view

            //call the method 'gridMemberColumn' from the controller

            'value'=>array($this,'gridEntryColumn'),

        ),

        array(

            'class'=>'CButtonColumn',

        ),

    ),

)); ?>

with gridEntryColumn defined as:


    protected function gridEntryColumn($data,$row)

    {

       $sql = 'SELECT entry_id, name, stud_name, member FROM lag_entry WHERE show_id = ' . $data->show_id .' ORDER BY name';

       $rows = Yii::app()->db->createCommand($sql)->queryAll();


       $result = '1';

       $idx = 1;

       if(empty($rows))

           foreach ($rows as $row)

           {

               $url = Yii::app()->createUrl('entry/view',array('entry_id'=>$row['entry_id']));

               $style = $idx % 2 == 0 ? 'background:#F8F8F8; padding:0.5em;' : 'background:#E5F1F4; padding:0.5em;';

               $text = CHtml::tag('div',array('style'=>$style),$row['name'].' '.$row['stud_name']);

               $result .= CHtml::link($text,$url) .'<br/>';

               $idx++;

           }

       return $result;

    }



now if I replace the TbGridZView with a CGridView it works correctly but I prefer a TbGridView. It appears more to be something to do with searching but I am not positive.

This is part of the stack trace:


Stack Trace

#0 	

+

 C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(85): htmlspecialchars(array(), 3, "UTF-8")

#1 	

+

 C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(2216): CHtml::encode(array())

#2 	

+

 C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(140): CHtml::renderAttributes(array("name" => "Rabbitshow[entries]", "type" => "text", "value" => array()))

#3 	

+

 C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(1890): CHtml::tag("input", array("name" => "Rabbitshow[entries]", "type" => "text", "value" => array()))

#4 	

+

 C:\xampp\htdocs\yii\framework\web\helpers\CHtml.php(1217): CHtml::activeInputField("text", Rabbitshow, "entries", array("name" => "Rabbitshow[entries]"))

#5 	

+

 C:\xampp\htdocs\yii\framework\zii\widgets\grid\CDataColumn.php(98): CHtml::activeTextField(Rabbitshow, "entries", array("id" => false)) 

Any ideas?

Change line:


'value'=>array($this,'gridEntryColumn'),

into something like this




'value'=>function($row){return $this->gridEntryColumn($model, $row)}



or




'value'=>"$this->gridEntryColumn($model, $row)"



Hi,

Thanks for that but neither worked and returned the same error.