Hi, CGridView deletes from DB properly if ID it is looking for is numeric. However, if it has letters in it, then it gives an error. Any ideas how to fix it? I believe it has to do something with csrf token validation. Any help would be appreciated.

ps I can’t paste error, as for some reason it’s vertical and goes beyond the screen, so I can’t get all of it.

upd: nevermind the csrf part

CGridView only generates a delete link… .the actual deletition is done in the actionDelete in the proper controller… so check that method… I assume you have something like (int)value… in that case you just need to remove the casting to int.

Upd: Just figured out it had nothing to do with CRSF token, sorry for confusion. But problem is still there

PK of the row is "00221917181E", of type varchar(20)

Here’s my delete action, it’s the default one that is generated by gii:

public function actionDelete($id)




			// we only allow deletion via POST request


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


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



			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');


and the load model method, also default one:

public function loadModel($id)




			throw new CHttpException(404,'The requested page does not exist.');

		return $model;


CGrid, in case you need it as well:

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












Solved. Was my own mistake, was using old version of code. Would have noticed earlier if error was showing correctly.