record; if (!$toDelete->canDelete()) { throw new ValidationException(_t('GridFieldDetailForm.DeletePermissionsFailure',"No delete permissions"),0); } $toDelete->delete(); } catch(ValidationException $e) { $form->sessionMessage($e->getResult()->message(), 'bad'); return Controller::curr()->redirectBack(); } $message = sprintf( _t('GridFieldDetailForm.Deleted', 'Deleted %s %s'), $this->record->singular_name(), '"' . htmlspecialchars($this->record->Title, ENT_QUOTES) . '"' ); $form->sessionMessage($message, 'good'); //when an item is deleted, redirect to the revelant admin section without the action parameter $controller = Controller::curr(); $noActionURL = $controller->removeAction($data['url']); $controller->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh return $controller->redirect($noActionURL, 302); //redirect back to admin section } }