I am a PHP Coder. But I just started using Smarty with Smarty Validation Plugin, for the development of my new Link Directory Software. I am stuck at something. its captcha validation. I am giving you an example of my code here : class test { var $a = 'say'; function say($param) { if ($this -> a == 'say') { echo $param; } return true; } } PHP: My smarty validation code : $test = new test; if (empty($_POST['submit'])) { SmartyValidate::connect($smarty, true); SmartyValidate::register_object('test', $test); SmartyValidate::register_criteria('Say','test->say'); SmartyValidate::register_validator('v_say','say','Say',false,false,'trim'); $smarty->display('form.tpl'); } else { // validate after a POST SmartyValidate::connect($smarty); if(SmartyValidate::is_valid($_POST) && $fatal != true) { // no errors, done with SmartyValidate $smarty -> display('form.tpl'); } else { // error, redraw the form $smarty->assign($_POST); $smarty->display('form.tpl'); } } PHP: My form.tpl : <form method="POST" action=""> {validate id="v_say" criteria="Say" message="error"} <input type="text" name="say" /> <input type="submit" name="submit" value="submit" /> </form> PHP: But everytime I use this form , it triggers this error: Notice: SmartyValidate: [is_valid] method 'say' is not valid for object 'test'. in D:\**********\smarty\SmartyValidate.class.php on line 604 Code (markup): Any idea why I am getting this error ?? :s I figured out that it means method 'say' doesnt exist in class 'test' ( anyone can figure out that much LOL ) but this isnt true Please help me
Isn't the validator looking for v_say's value? Your input is returning a value for "say" Of course, I haven't looked at SmartyValidate in about 2 years. :shrug: So don't take my word for it, unless it works. cheers, gary
huh, there is nothing wrong with the validator's code. it is the right way to do it, but for some reason it doesnt work. i think it is a bug. and i thought you knew how to fix it, but i was wrong.. anyway, thanks for reply.. but i was expecting a useful reply
No, not with the validator code. I was thinking that this <input type="text" name="say" /> Code (markup): should be <input type="text" name="v_say" /> Code (markup): gary
nope it shouldnt be v_say, again I am saying, my tpl file is 100% correct , read their documentation again please Update : ah, figured it out, i just had to add register_object after the next connect too thanks for your time though..