I’m having some problems deleting with pagination switched on.
I’ve added a delete link to a customised index page which works fine under normal circumstances but after adding pagination in the data provider, if I attempt to delete an item from page 2 it actually removes the equivalent item from the first page (deleting first item in page 2 deletes first item in page 1; deleting second item in page 2 deletes second item in page 1, etc).
Here are my controller’s index and delete actions:
public function actionIndex()
$vehicles = Vehicle::model()->vehiclesOfLoggedInUser();
$dataProvider = new CArrayDataProvider($vehicles, array(
'registration', 'make', 'model'),
'keyField' => 'vehicle_id',
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('index'));
throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
And the delete link in my view:
<?php echo CHtml::Link('Delete Vehicle', '#', array('submit'=>array('vehicle/delete','id'=>$data->vehicle_id),'confirm'=>'Are you sure?'));
I’m assuming it’s because the contents of the second page isn’t available to POST but is there away to fix this?
Thanks for taking the time to reply and for the info - that looks like the same issue. I’m not clear what the issue tracker is saying - seems it’s closed but presumably wasn’t fixed in 1.1.10. Is it still outstanding then? If so, is there any approach I can try to get around it that you can suggest?