View previous topic :: View next topic |
Author |
Message |
isiposs Smarty Rookie
Joined: 05 Mar 2005 Posts: 9 Location: Santa Rosa, CA, USA
|
Posted: Tue Mar 08, 2005 9:51 am Post subject: SmartyValidate bug (empty=yes) |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 08, 2005 2:36 pm Post subject: |
|
|
blank="yes" is not a valid parameter, but lets see the template? |
|
Back to top |
|
isiposs Smarty Rookie
Joined: 05 Mar 2005 Posts: 9 Location: Santa Rosa, CA, USA
|
Posted: Tue Mar 08, 2005 4:54 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 08, 2005 5:02 pm Post subject: |
|
|
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 |
|
isiposs Smarty Rookie
Joined: 05 Mar 2005 Posts: 9 Location: Santa Rosa, CA, USA
|
Posted: Tue Mar 08, 2005 6:10 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 08, 2005 7:13 pm Post subject: |
|
|
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 |
|
isiposs Smarty Rookie
Joined: 05 Mar 2005 Posts: 9 Location: Santa Rosa, CA, USA
|
Posted: Tue Mar 08, 2005 8:58 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 08, 2005 9:44 pm Post subject: |
|
|
It seems to work OK for me (?) |
|
Back to top |
|
isiposs Smarty Rookie
Joined: 05 Mar 2005 Posts: 9 Location: Santa Rosa, CA, USA
|
Posted: Tue Mar 08, 2005 11:10 pm Post subject: |
|
|
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 |
|
|