Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

SmartValidate fails on empty field

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
Boby
Smarty Rookie


Joined: 21 Jan 2006
Posts: 21

PostPosted: Sat Apr 08, 2006 7:24 pm    Post subject: SmartValidate fails on empty field Reply with quote

Hello!

I updated the SmartyValidate plugin for one of my application to the latest version and it's not working anymore.
I have a field where a user can enter a URL, it's eighter optional or not, depending on the admin preferences.

This is my code:
Code:
SmartyValidate :: register_validator('v_RECPR_URL', 'RECPR_URL', 'isURL', ($url_required ? true : false), false, 'trim', 'submit_link');


If an URL is entered, the validation works, if the field is left empty it fails. Even if I give this to make sure it is set to allow the field to be empty:
Code:
SmartyValidate :: register_validator('v_RECPR_URL', 'RECPR_URL', 'isURL', true, false, 'trim', 'submit_link');


I am sure I turned the field to be optional in admin panel.

This works great with SmartyValidate 2.4 Wink Is there anything I missed during the other updates?

Thank you very much for your help!

Kind regards, Boby.
_________________
My Homepage: www.frozenminds.com
Back to top
View user's profile Send private message Visit poster's website
Boby
Smarty Rookie


Joined: 21 Jan 2006
Posts: 21

PostPosted: Sat Apr 08, 2006 10:28 pm    Post subject: Reply with quote

Ok, I have found now SmartyValidate 2.6 and it works perfect with this one. Also with SmartyValidate 2.5/2.4 so I assume it's a bug in 2.7

I have tested with:
  • CentOS 4.2 Linux
    Apache 2.0
    PHP 4.3.9
    MySQL 4.1
  • Fedora Core 5 Linux
    Apache 2.2
    PHP 5.1.2
    MySQL 5.0.18
  • XAMPP on Fedora Core 5 Linux
    Apache 2.2
    PHP 5.1.1 and 4.4.1
    MySQL 5.0.18
  • XAMPP on Windows XP - SP2
    Apache 2.2
    PHP 5.1.1 and 4.4.1
    MySQL 5.0.18


Boby
_________________
My Homepage: www.frozenminds.com
Back to top
View user's profile Send private message Visit poster's website
robrosko
Smarty n00b


Joined: 13 Apr 2006
Posts: 3

PostPosted: Thu Apr 13, 2006 9:07 pm    Post subject: Reply with quote

I've started using SmartyValidate some days ago. And I stumbled on the same thing. I just have one field on the form. It is allowed to be empty so I passed true for empty on register_validator. But it did not validate to true.
Research in the code(CVS) revealed line 211:

Code:
$_ret = !$_ret ? false : $_empty;


This does not make any sense to me. If I understood it right then $_ret should contain an array of failed fields as this block which comes later indicates:

Code:
if(!$_sess[$_key]['valid']) {
  $_ret[] = $_full_field;
  if(isset($_sess[$_key]['halt']) && $_sess[$_key]['halt'])
    break;
}


So, by just commenting out line 211 it seems to work fine. But don't blame me if it does not work as expected.

Rob
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Apr 14, 2006 11:12 pm    Post subject: Reply with quote

This is fixed in CVS.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP