Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG Gridfield fails when save changes filter criteria (fixes #7785)

  • Loading branch information...
commit 52263e6a5f593b72d059d778cb916a6eb550418b 1 parent d24ea5e
@chillu chillu authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 forms/gridfield/GridFieldDetailForm.php
View
10 forms/gridfield/GridFieldDetailForm.php
@@ -364,6 +364,7 @@ protected function getToplevelController() {
function doSave($data, $form) {
$new_record = $this->record->ID == 0;
+ $controller = Controller::curr();
try {
$form->saveInto($this->record);
@@ -371,7 +372,6 @@ function doSave($data, $form) {
$this->gridField->getList()->add($this->record);
} catch(ValidationException $e) {
$form->sessionMessage($e->getResult()->message(), 'bad');
- $controller = Controller::curr();
$responseNegotiator = new PjaxResponseNegotiator(array(
'CurrentForm' => function() use(&$form) {
return $form->forTemplate();
@@ -398,10 +398,16 @@ function doSave($data, $form) {
if($new_record) {
return Controller::curr()->redirect($this->Link());
- } else {
+ } elseif($this->gridField->getList()->byId($this->record->ID)) {
// Return new view, as we can't do a "virtual redirect" via the CMS Ajax
// to the same URL (it assumes that its content is already current, and doesn't reload)
return $this->edit(Controller::curr()->getRequest());
+ } else {
+ // Changes to the record properties might've excluded the record from
+ // a filtered list, so return back to the main view if it can't be found
+ $noActionURL = $controller->removeAction($data['url']);
+ $controller->getRequest()->addHeader('X-Pjax', 'Content');
+ return $controller->redirect($noActionURL, 302);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.