mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
FIX #7787 Handles ajax and normal requests differently when validation fails on gridfields
This commit is contained in:
parent
70b22fa4ca
commit
14759b6ff1
@ -371,7 +371,19 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler {
|
||||
$this->gridField->getList()->add($this->record);
|
||||
} catch(ValidationException $e) {
|
||||
$form->sessionMessage($e->getResult()->message(), 'bad');
|
||||
return Controller::curr()->redirectBack();
|
||||
$controller = Controller::curr();
|
||||
$responseNegotiator = new PjaxResponseNegotiator(array(
|
||||
'CurrentForm' => function() use(&$form) {
|
||||
return $form->forTemplate();
|
||||
},
|
||||
'default' => function() use(&$controller) {
|
||||
return $controller->redirectBack();
|
||||
}
|
||||
));
|
||||
if($controller->getRequest()->isAjax()){
|
||||
$controller->getRequest()->addHeader('X-Pjax', 'CurrentForm');
|
||||
}
|
||||
return $responseNegotiator->respond($controller->getRequest());
|
||||
}
|
||||
|
||||
// TODO Save this item into the given relationship
|
||||
|
Loading…
x
Reference in New Issue
Block a user