I need some custom validation in a popup, but in the code the validator get unset specifically.
File: DataObjectManager.php
Line: 792
Code: $this->unsetValidator();
Why is this??
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba
I need some custom validation in a popup, but in the code the validator get unset specifically.
File: DataObjectManager.php
Line: 792
Code: $this->unsetValidator();
Why is this??
Javascript conflicts.. that validator brings in prototype and all sorts of junk. You can try enabling it again, but I've never had any luck with it. Much better to use jQuery based validation.
Wouldn't it be better to just disable the javascript validation handler in that case?
Then you could atleast still use server side validation
$validator->setJavascriptValidationHandler('none');
parent::__construct($controller, $name, $fields, $actions, $validator);
// $this->unsetValidator();
Yup. That's some old code you're looking at.
I'm using the latest version of DOM from the trunk.
Are you going to include this in your next release?
Here's an updated code snippet which i think should be included in the DOM
// disable javascript validation to prevent JS errors
if (!empty($validator) && $validator instanceof Validator) {
$validator->setJavascriptValidationHandler('none');
}
parent::__construct($controller, $name, $fields, $actions, $validator);
// $this->unsetValidator();
*bump*
This still needs to be patched in
parent::__construct($controller, $name, $fields, $actions, $validator);
if ($this->validator instanceof Validator) {
$this->validator->setJavascriptValidationHandler('none');
} else {
$this->unsetValidator();
}