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

SmartyValidate bug (empty=yes)

 
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 -> Plugins
View previous topic :: View next topic  
Author Message
isiposs
Smarty Rookie


Joined: 05 Mar 2005
Posts: 9
Location: Santa Rosa, CA, USA

PostPosted: Tue Mar 08, 2005 9:51 am    Post subject: SmartyValidate bug (empty=yes) Reply with quote

I seem to have found a minor bug in SmartyValidate (couldn't fix it, sorry.) I had a form with two fields, Event, and Eventdate. Event had to be filled in, so I used notEmpty. Eventdate, had to be a date but in this particular case, it wasn't required, so I used isDate blank="yes". However, SmartyValidate didn't let me leave Eventdate blank. It wasn't until I changed the form field's name from Eventdate to just Date that it started working correctly, so it appears that the "empty=yes" parameter got lost somehow when the two fields began the same way (i.e. Event and Eventdate.)

Istvan Siposs
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Tue Mar 08, 2005 2:36 pm    Post subject: Reply with quote

blank="yes" is not a valid parameter, but lets see the template?
Back to top
View user's profile Send private message Visit poster's website
isiposs
Smarty Rookie


Joined: 05 Mar 2005
Posts: 9
Location: Santa Rosa, CA, USA

PostPosted: Tue Mar 08, 2005 4:54 pm    Post subject: Reply with quote

Sorry, I meant "empty=yes". This version didn't let blank Eventdates through:

Code:

  <tr>
    <td>Event:</td>
    <td>
       <input type="text" name="Event" size="50" value="{$Event|escape}" maxlength=100>
       <div class=formerror>{validate form="frmCreateRegistry" field="Event" criteria="notEmpty" message="Please enter the event."}</div>
    </td>
  </tr>
  <tr>
    <td>Date:</td>
    <td>
       <input type="text" name="Eventdate" size="10" value="{$Eventdate|escape}">
       <div class=formerror>{validate form="frmCreateRegistry" field="Eventdate" empty="yes" criteria="isDate" message="Please enter a valid date or leave blank."}</div>
    </td>
  </tr>


When I changed the form field Eventdate to just Date, it then worked.

Istvan
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Tue Mar 08, 2005 5:02 pm    Post subject: Reply with quote

If you are developing and you change anything in the templates, you should wipe out the session data to be sure there are no problems:

SmartyValidate::connect($smarty,true);
Back to top
View user's profile Send private message Visit poster's website
isiposs
Smarty Rookie


Joined: 05 Mar 2005
Posts: 9
Location: Santa Rosa, CA, USA

PostPosted: Tue Mar 08, 2005 6:10 pm    Post subject: Reply with quote

It looks like the problem was because the two field names began the same way (Event and Eventdate). Once I changed Eventdate to Date it worked. That's what lead me to beleive that there is something with the plugin.

Istvan
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Tue Mar 08, 2005 7:13 pm    Post subject: Reply with quote

There are some validators like makeDate that use the fieldname as a prefix for the three form fields that make up the actual date... maybe that is part of it?
Back to top
View user's profile Send private message Visit poster's website
isiposs
Smarty Rookie


Joined: 05 Mar 2005
Posts: 9
Location: Santa Rosa, CA, USA

PostPosted: Tue Mar 08, 2005 8:58 pm    Post subject: Reply with quote

Could be. Did you write the plugin? If so, you can easily replicate this by looking at my code (template). If you name the first field Event, and make it required, then make the second Eventdate and set "empty=yes".

Istvan
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Tue Mar 08, 2005 9:44 pm    Post subject: Reply with quote

It seems to work OK for me (?)
Back to top
View user's profile Send private message Visit poster's website
isiposs
Smarty Rookie


Joined: 05 Mar 2005
Posts: 9
Location: Santa Rosa, CA, USA

PostPosted: Tue Mar 08, 2005 11:10 pm    Post subject: Reply with quote

That's strange, could you post your template and code here so that I can compare it to what I had?

Istvan
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 -> Plugins 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