Daily Archives: August 9, 2013

How to add buttons to CGridView when using CArrayDataProvider 1

By default, the button’s used by CGridView expect an array of objects having an “id” property that it can use with the edit and delete buttons. If you’re using CArrayDataProvider, this won’t work. I was able to get the below code working for a delete button. Note that you have to specify the button you want in the “template” attribute, otherwise it’ll try to build all the buttons using the non existent id property.

				'template' => '{delete}',
				'buttons' => array(
					'delete' => array(
							'url' => 'Yii::app()->controller->createUrl("mycontroller/myaction", array("name"=>$data["name"]))',