Normal Button In Cgridview

Hi there,

I am trying to put in just a regular <button> element into a column in CGridView. If I use this:


    'header' => '&nbsp;',

    'value' => 'CHtml::tag("button", array(

        'type' => 'button',

        'class' => 'btn',

    ), "Edit")',

    'type' => 'html',


It strips out the HTML leaving just “Edit” in the <td></td>. If I use the CHtml::button() method, nothing appears. If I use ‘type’ => ‘text’, then it HTML encodes the string and the actual HTML is seen in the cell.

I thought maybe CButtonColumn would be the answer, but these "buttons" are really link images.

How can I place a <button> element in the cell?

Thank you!

i don’t know i understood you properly or not? :unsure: but i think you want to add new button in CGridView. if you are looking for this then you can add button by adding following code.

$this->widget('zii.widgets.grid.CGridView', array(

















hope it may help you…


What happens if you set the ‘type’ as ‘raw’?

The CButtonColumn is very flexible. You can customise those links or add new ones, as kalpit explained. This tutorial describes the flexibility of the CButtonColumn.

You can use :


	    'header'=&gt;&quot;Header Text&quot;,


	    'value'=&gt;'CHtml::link(getStatus(), Yii::app()-&gt;createUrl(Path of controller))',



Outside Grid:

function getStatus($type)


	return  '&lt;button type=&quot;submit&quot;&gt;&lt;/button&gt;';



check this wiki

This is the correct answer! Don’t know how I missed the ‘raw’ type, but that got the button in there.

Thanks, BlkRaven!