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.

All other Modules /

Discuss all other Modules here.

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

Unable to use NetefxValidatorRuleFUNCTION with MyLibrary


Go to End


717 Views

Avatar
Sandhya

Community Member, 6 Posts

11 March 2013 at 6:35pm

Hello,

I have built a custom form.. When I tried to put validation I am not able to retain the posted values after the validation is fired. Various sites recommended the use of NetefxValidator module. However, I tried to create my own library for validation but NetefxValidatorRuleFUNCTION returns null. Please help.

Following is what i did in my code:

As per the documentation, I created a class file MyLibrary.php in mysite/code

$rule_startTime_Max = new NetefxValidatorRuleFUNCTION ("StartTime", "Start time cannot be greater than end time", 'error',array('MyLibrary', 'startTimeLessThanEndTime', array()))

class MyLibrary {

public static function startTimeLessThanEndTime($data, $args) {
return true;
}

}

But the validation is fired every time. Also I tried print_r($data);exit(); but NetefxValidatorRuleFUNCTION .php

return call_user_func_array($function, $params);

always returns null...