Update one field when deleting a record

Hi All,

When I delete records from CGridView, I just change a "flag" from 0 to 1.




public function actionDelete($id)

{

	$model=$this->loadModel($id);

	$model->flag=1;

	$model->save();


	// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser

	if(!isset($_GET['ajax']))

		$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));

}



In every table I have a field "comments", and I would like to update this field when "deleting".

Eg. when user deletes a record from CGridView, not only the flag is changed from 0 to 1,

but I want to display (maybe in a popup) just the "comments" field so he/she can write why was this record "deleted".

How can I achieve this? Please help…

Thank you in advance.

As much as my understanding, you have to overwrite the delete functionality. May replace the default delete button with the custom one, popup comment box and pass the comments with the id to the delete action that you already modified.

to add custom button you may follow

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

or I will post some sample code if required.

Thank you Jawwad for your reply.

For now I just added an extra view containing only the comment field.

And a custom button refering to an action "cancel", the same like update

and that renders this view for updating the comment field.

It loads as a normal page for now, maybe later I do it in CJuiDialog.