mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
API CHANGE Using RequiredFields or DataObject->getCMSValidator() in CMSMain->getEditForm(), which means all pages in the CMS will have validation enabled, e.g. for date fields. This is necessary to avoid a global disabling of javascript validation through Validator::set_javascript_validation_handler('none') breaking the CMS, which relies on javascript responses through Form->validate() and the FormResponse class (without specifically requesting them through HTTP Accept headers). See #3386 and #2915
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@73336 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
a78ce1998e
commit
be985afd24
@ -426,7 +426,27 @@ JS;
|
||||
}
|
||||
}
|
||||
}
|
||||
$form = new Form($this, "EditForm", $fields, $actions);
|
||||
|
||||
// Add a default or custom validator.
|
||||
// @todo Currently the default Validator.js implementation
|
||||
// adds javascript to the document body, meaning it won't
|
||||
// be included properly if the associated fields are loaded
|
||||
// through ajax. This means only serverside validation
|
||||
// will kick in for pages+validation loaded through ajax.
|
||||
// This will be solved by using less obtrusive javascript validation
|
||||
// in the future, see http://open.silverstripe.com/ticket/2915 and http://open.silverstripe.com/ticket/3386
|
||||
if($record->hasMethod('getCMSValidator')) {
|
||||
$validator = $record->getCMSValidator();
|
||||
} else {
|
||||
$validator = new RequiredFields();
|
||||
}
|
||||
|
||||
// The clientside (mainly LeftAndMain*.js) rely on ajax responses
|
||||
// which can be evaluated as javascript, hence we need
|
||||
// to override any global changes to the validation handler.
|
||||
$validator->setJavascriptValidationHandler('prototype');
|
||||
|
||||
$form = new Form($this, "EditForm", $fields, $actions, $validator);
|
||||
$form->loadDataFrom($record);
|
||||
$form->disableDefaultAction();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user