Jump to:

10931 Posts in 2614 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » Unable to use NetefxValidatorRuleFUNCTION with MyLibrary

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 241 Views
  • Sandhya
    Avatar
    Community Member
    6 Posts

    Unable to use NetefxValidatorRuleFUNCTION with MyLibrary Link to this post

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

    241 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.