mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG Gridfield fails when save changes filter criteria (fixes #7785)
This commit is contained in:
parent
d24ea5ec97
commit
52263e6a5f
@ -364,6 +364,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
|
|||||||
|
|
||||||
function doSave($data, $form) {
|
function doSave($data, $form) {
|
||||||
$new_record = $this->record->ID == 0;
|
$new_record = $this->record->ID == 0;
|
||||||
|
$controller = Controller::curr();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$form->saveInto($this->record);
|
$form->saveInto($this->record);
|
||||||
@ -371,7 +372,6 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
|
|||||||
$this->gridField->getList()->add($this->record);
|
$this->gridField->getList()->add($this->record);
|
||||||
} catch(ValidationException $e) {
|
} catch(ValidationException $e) {
|
||||||
$form->sessionMessage($e->getResult()->message(), 'bad');
|
$form->sessionMessage($e->getResult()->message(), 'bad');
|
||||||
$controller = Controller::curr();
|
|
||||||
$responseNegotiator = new PjaxResponseNegotiator(array(
|
$responseNegotiator = new PjaxResponseNegotiator(array(
|
||||||
'CurrentForm' => function() use(&$form) {
|
'CurrentForm' => function() use(&$form) {
|
||||||
return $form->forTemplate();
|
return $form->forTemplate();
|
||||||
@ -398,10 +398,16 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
|
|||||||
|
|
||||||
if($new_record) {
|
if($new_record) {
|
||||||
return Controller::curr()->redirect($this->Link());
|
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
|
// 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)
|
// to the same URL (it assumes that its content is already current, and doesn't reload)
|
||||||
return $this->edit(Controller::curr()->getRequest());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user