Jump to:

10930 Posts in 2613 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » NetefxValidator

Discuss all other Modules here.

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

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

    Re: NetefxValidator Link to this post

    I am a newbie to Silverstripe. I dont know where am I going incorrect. But I am getting the message "Fatal error: Call to a member function validate() on a non-object in D:\xampp\htdocs\sffc_dev\NetefxValidator\code\NetefxValidator.php on line 66" on form submit. Please help..

    I am trying to use NetefxValidator on my checkout page

    Attached Files
  • lx
    Avatar
    Community Member
    82 Posts

    Re: NetefxValidator Link to this post

    Hi Sandhya,

    please paste your code. Maybe you did something wrong with the validator.

  • Sandhya
    Avatar
    Community Member
    6 Posts

    Re: NetefxValidator Link to this post

    Hi lx,

    Below is my code:

    $requiredFields is the list of all the required fields on my form

    Array
    (
    [0] => FirstName
    [1] => Lastname
    [2] => Email
    [3] => Address
    [4] => City
    [5] => Country
    [6] => S_Name
    [7] => S_Address
    [8] => S_City
    [9] => S_Country
    [10] => Pwd[_Pwd]
    [11] => Pwd[_ConPwd]
    [12] => CM_Name
    [13] => CM_Address
    [14] => CM_Telephone
    [15] => CM_Email
    [16] => CM_DOB
    [17] => CM_Company
    )

    foreach($requiredFields as $requiredField){
       $rule_Required[] = new NetefxValidatorRuleREQUIRED($requiredField, "Please enter your $requiredField", 'error');
    }
    $validator = new NetefxValidator($rule_Required);
    $this->extend('updateValidator',$validator);
    parent::__construct($controller, $name, $fields, $actions, $validator);

    I am making these changes on OrderForm of the ecommerce module

  • Sandhya
    Avatar
    Community Member
    6 Posts

    Re: NetefxValidator Link to this post

    Hi LX,

    I got the solution. Thanks for your prompt reply.

  • Sandhya
    Avatar
    Community Member
    6 Posts

    Re: NetefxValidator Link to this post

    I have one more question. How do I set the priorities of the validations? i.e. Say For example Email Field. Now, Email is required as well as it has a REGEXP to be validated. Now, if Email is not entered is shouldn't check REGEXP validation. But I find that the required field validation is overwritten. Can anyone help?

  • lx
    Avatar
    Community Member
    82 Posts

    Re: NetefxValidator Link to this post

    Hi sandhya,

    I never used the validator as an extension. If you needed to fix something in the netefxvalidator to get it working, it would be nice if you could make a pull request on github.

    There is no property in a rule for its priority. Its just the order of the rules that matters.
    So, add the regexp rule and then the required rule to the validator.

    Regards
    Lx

  • Sandhya
    Avatar
    Community Member
    6 Posts

    Re: NetefxValidator Link to this post

    Hi Lx,

    Thankyou for the response. It worked.

    Regards,
    Sandhya

    4319 Views
Page: 1 2 3
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.