10447 Posts in 2223 Topics by 1719 members
| Go to End | ||
| Author | Topic: | 3069 Views |
-
Re: NetefxValidator

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
-
Re: NetefxValidator

14 February 2013 at 10:41pm
Hi Sandhya,
please paste your code. Maybe you did something wrong with the validator.
-
Re: NetefxValidator

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
-
Re: NetefxValidator

15 February 2013 at 9:23pm
Hi LX,
I got the solution. Thanks for your prompt reply.
-
Re: NetefxValidator

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?
-
Re: NetefxValidator

15 February 2013 at 10:01pm Last edited: 15 February 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 -
Re: NetefxValidator

16 February 2013 at 1:42am
Hi Lx,
Thankyou for the response. It worked.
Regards,
Sandhya
| 3069 Views | ||
| Go to Top |

