Adding a confirm delete popup to Yii admin form


I wanted to share this bit I was able to get working today with my Yii application. Add the JavaScript confirm dialog to the “htmlOptions” array key as below –

<?php $this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'menu-block-grid',
	'dataProvider'=>$model->search(),
	'type'=>'striped bordered condensed',
	'filter'=>$model,
	'columns'=>array(
		'id',
		'location',
		'sort_order',
		'name',
		'href',
		array(
			'class'=>'bootstrap.widgets.TbButtonColumn',
			'htmlOptions'=>array('onclick'=>'return confirm("Are you sure?")'),
		),
	),
)); ?>

Leave a comment

Your email address will not be published. Required fields are marked *