I am trying to validate a phone field in Formit by using custom hooks. The phone format must be ###-###-####. However, when I using getValues() in my snippet, I receive 500 server error. The error from the error logs reads:
PHP Fatal error: Call to a member function getValues() on a non-object in /home/user/www/core/cache/includes/elements/modsnippet/34.include.cache.php on line 9, referer:
http://www.mywebsite.com/en/contact-form
Here is my code:
[[!FormIt?
&hooks=`recaptcha,spam,FormSave,email,redirect`
&customValidators=`FacebookCountryRedirect`
&emailTpl=`FbContactEmailTpl`
&emailSubject=`Facebook Contact Form`
&emailTo=`
[email protected]`
&fsFormTopic=`Facebook Contact`
&validate=`country:required,
fname:required,
lname:required,
mobile:FacebookCountryRedirect,
email:email:required,
vehicle-make-model:required,
age:required,
agreement:required`
&redirectTo=`2`
&redirectParams=`{"country":"[[!+fi.country]]"}`
]]
SNIPPET
<?php
$hook = $scriptProperties['hook'];
$country='';
if( is_object($hook) ){
$countries = $hook->getValue('fname');
if ($countries == 'Jevon')
{
$country='Anguilla';
}
}
else{ $countries='batman';}
return $countries;
Can anyone please help me with this issue?
[ed. note: random_noob last edited this post 12 years, 3 months ago.]