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.

All other Modules /

Discuss all other Modules here.

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

NetefxValidator


Go to End
Reply


23 Posts   4731 Views

Avatar
Sandhya

Community Member, 6 Posts

14 February 2013 at 9:50pm

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
Avatar
lx

Community Member, 83 Posts

14 February 2013 at 10:41pm

Hi Sandhya,

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

Avatar
Sandhya

Community Member, 6 Posts

14 February 2013 at 11:02pm

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

Avatar
Sandhya

Community Member, 6 Posts

15 February 2013 at 9:23pm

Hi LX,

I got the solution. Thanks for your prompt reply.

Avatar
Sandhya

Community Member, 6 Posts

15 February 2013 at 9:31pm

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?

Avatar
lx

Community Member, 83 Posts

15 February 2013 at 10:01pm

Edited: 15/02/2013 10:03pm

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

Avatar
Sandhya

Community Member, 6 Posts

16 February 2013 at 1:42am

Hi Lx,

Thankyou for the response. It worked.

Regards,
Sandhya

Go to Top