Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Validation in DataObjectManager_Popup


Go to End


7 Posts   1388 Views

Avatar
Mad_Clog

Community Member, 78 Posts

10 June 2010 at 2:55am

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??

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 June 2010 at 3:14am

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.

Avatar
Mad_Clog

Community Member, 78 Posts

10 June 2010 at 3:33am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 June 2010 at 3:40am

Yup. That's some old code you're looking at.

Avatar
Mad_Clog

Community Member, 78 Posts

10 June 2010 at 3:45am

I'm using the latest version of DOM from the trunk.
Are you going to include this in your next release?

Avatar
Mad_Clog

Community Member, 78 Posts

17 June 2010 at 1:12am

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

Avatar
Mad_Clog

Community Member, 78 Posts

13 August 2010 at 6:14am

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