Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FIX #7787 Handles ajax and normal requests differently when validatio…

…n fails on gridfields
  • Loading branch information...
commit 14759b6ff12a16422d63c1c70bd4cb36f3132739 1 parent 70b22fa
@patbolo patbolo authored chillu committed
Showing with 13 additions and 1 deletion.
  1. +13 −1 forms/gridfield/GridFieldDetailForm.php
View
14 forms/gridfield/GridFieldDetailForm.php
@@ -371,7 +371,19 @@ function doSave($data, $form) {
$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
Please sign in to comment.
Something went wrong with that request. Please try again.