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:
Andrew Short 2013-10-09 23:27:56 +11:00
parent 55c6f35e15
commit ed9f8dcf1f

View File

@ -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();
}