I’ve a table turned into CModel, and a CController with admin/delete actions. But, by the fact that the ID of the table is alphanumeric random-generated string, the action delete failed with the response ‘Your request is invalid.’
If I try to call the action with some numeric ID, the request is processed successfuly.
the code for the delete action:
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'manage' page.
* @param string $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
if(Yii::app()->request->isPostRequest)
{
// we only allow deletion via POST request
$this->loadModel($id)->delete();
// 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('manage'));
}
else
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
How could I make it work with alphanumeric IDs?