mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG: Fix CMS forms with validation errors responding incorrectly.
A new form instance was being constructed for the response, which mean that a lot of the validation information was lost. This fix means that: * Enterered data is correctly persisted. * A validation error notification is displayed.
This commit is contained in:
parent
55c6f35e15
commit
ed9f8dcf1f
@ -28,9 +28,16 @@ class CMSForm extends Form {
|
||||
protected function getValidationErrorResponse() {
|
||||
$request = $this->getRequest();
|
||||
$negotiator = $this->getResponseNegotiator();
|
||||
|
||||
if($request->isAjax() && $negotiator) {
|
||||
$negotiator->setResponse(new SS_HTTPResponse($this));
|
||||
return $negotiator->respond($request);
|
||||
$this->setupFormErrors();
|
||||
$result = $this->forTemplate();
|
||||
|
||||
return $negotiator->respond($request, array(
|
||||
'CurrentForm' => function() use($result) {
|
||||
return $result;
|
||||
}
|
||||
));
|
||||
} else {
|
||||
return parent::getValidationErrorResponse();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user