mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Removed FormResponse handling for erroneous ajax requests in Form->validate(), use javascript validation instead, or reload the whole form with new HTML including the error messages
This commit is contained in:
parent
85a331cc11
commit
c2339d2181
@ -1015,23 +1015,10 @@ class Form extends RequestHandler {
|
|||||||
$errors = $this->validator->validate();
|
$errors = $this->validator->validate();
|
||||||
|
|
||||||
if($errors){
|
if($errors){
|
||||||
if(Director::is_ajax() && $this->validator->getJavascriptValidationHandler() == 'prototype') {
|
// Load errors into session and post back
|
||||||
FormResponse::status_message(_t('Form.VALIDATIONFAILED', 'Validation failed'), 'bad');
|
$data = $this->getData();
|
||||||
foreach($errors as $error) {
|
Session::set("FormInfo.{$this->FormName()}.errors", $errors);
|
||||||
FormResponse::add(sprintf(
|
Session::set("FormInfo.{$this->FormName()}.data", $data);
|
||||||
"validationError('%s', '%s', '%s');\n",
|
|
||||||
Convert::raw2js($error['fieldName']),
|
|
||||||
Convert::raw2js($error['message']),
|
|
||||||
Convert::raw2js($error['messageType'])
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$data = $this->getData();
|
|
||||||
|
|
||||||
// Load errors into session and post back
|
|
||||||
Session::set("FormInfo.{$this->FormName()}.errors", $errors);
|
|
||||||
Session::set("FormInfo.{$this->FormName()}.data", $data);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user