Problem creating custom buttons in CButtonColumn

Hi folks,

i read this article:

http://www.yiiframework.com/wiki/106/using-cbuttoncolumn-to-customize-buttons-in-cgridview/

The author used the following code to create custom buttons for his CGridView CButtonColumn:


array

(

    'class'=>'CButtonColumn',

    'template'=>'{email}{down}{delete}',

    'buttons'=>array

    (

        'email' => array

        (

            'label'=>'Send an e-mail to this user',

            'imageUrl'=>Yii::app()->request->baseUrl.'/images/email.png',

            'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->id))',

        ),

        'down' => array

        (

            'label'=>'[-]',

            'url'=>'"#"',

            'visible'=>'$data->score > 0',

            'click'=>'function(){alert("Going down!");}',

        ),

    ),

),

But if i use the code i get an exception (yii/framework/zii/widgets/grid/CGridView.php(337)) saying

Looks like there’s something wrong with the template-string… also tried {email:foo:bar} and stuff, but didn’t work

I’m using yii 1.1.10.

Any ideas?

Thank you

Hi boehmi, welcome to the forum.

It sounds like the error might not be in the code that you quoted, but in other parts of your code for CGridView.

Make sure you will get no error when you have commented out those lines for CButtonColumn.