View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Mar 29, 2006 10:27 pm Post subject: SmartyValidate 2.7 released |
|
|
2.7 March 29, 2006
------------------
* add SMARTY_VALIDATE_DEFAULT_FORM constant (kills, monte)
* split up is_valid process for easier method subclassing (kills, monte)
* fix more PHP 5 date problems (kills, monte)
* fix PHP 5.1 problem with isDate (sguillory6, monte)
* fix bug with duplicate error messages (monte)
* fix problem when is_valid() called multiple times (monte)
* fix problem with testing array keys in zero-index fields (andrea_c75,monte)
* fix undefined index notice (Temas, monte)
http://www.phpinsider.com/php/code/SmartyValidate/ |
|
Back to top |
|
TGKnIght Smarty Junkie
![](images/avatars/gallery/Avatar_Pack_1/523.gif)
Joined: 07 Sep 2005 Posts: 580 Location: Philadelphia, PA
|
Posted: Fri Mar 31, 2006 5:02 pm Post subject: |
|
|
Hmm when I upgrade to 2.7 validation no longer works in my application... I keep getting an error
[php:1:e59518eeac]
Warning: in_array() [function.in-array]: Wrong datatype for second argument in C:\Sites\tsmFramework2\classes\smarty\SmartyValidate.class.php on line 143
[/php:1:e59518eeac]
When I put the version 2.6 class back in place everything works as normal.
I don't understand why this is happening as the $_ret var is being init'd as an array.. Perhaps elsewhere it is being set to a scalar var? _________________ Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Mar 31, 2006 7:49 pm Post subject: |
|
|
Try changing that:
[php:1:2ff67128db]if(is_array($_ret) && in_array($_full_field, $_ret)) {[/php:1:2ff67128db]
(kills, this is in the _failed_fields() method) |
|
Back to top |
|
tpr Smarty Rookie
Joined: 27 Mar 2006 Posts: 8
|
Posted: Sat Apr 01, 2006 6:37 am Post subject: |
|
|
this is great! I love what you can do with smarty.
a cool feature would be the ability to specify a class that gets used if an error occurs.
something like
{validate id="fname" class="error" message="Full Name cannot be empty"}
that renders like
<span class="error">Full Name cannot be empty</span>
I know i could wrap the {validate} in a span but that span gets rendered every time whether there is an error or not. Just a thought.
Keep up the great work!! |
|
Back to top |
|
tpr Smarty Rookie
Joined: 27 Mar 2006 Posts: 8
|
Posted: Sat Apr 01, 2006 7:03 am Post subject: |
|
|
see below
Last edited by tpr on Sat Apr 01, 2006 7:05 am; edited 1 time in total |
|
Back to top |
|
tpr Smarty Rookie
Joined: 27 Mar 2006 Posts: 8
|
Posted: Sat Apr 01, 2006 7:05 am Post subject: |
|
|
I came up with a better solution for my suggesting.
Code: |
<div style="display:{$error|default:none}">
<tr>
<td>&</td>
<td class="error" style="padding: 10px;">
{validate id="vname" message="& Name cannot be empty<br />"}
{validate id="vband" message="& Band cannot be empty<br />"}
{validate id="vaddress" message="& Address cannot be empty<br />"}
{validate id="vcity" message="& City cannot be empty<br />"}
{validate id="vstate" message="& State cannot be empty<br />"}
{validate id="vzip" message="& Zip cannot be empty<br />"}
{validate id="vphone" message="& Phone cannot be empty<br />"}
{validate id="vemail" message="& Email cannot be empty<br />"}
{validate id="vemailvalid" message="& Email must be valid<br />"}
</td>
</tr>
</div>
|
if error occurs
Code: |
$smarty->assign('error','inline');
|
|
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Tue Apr 04, 2006 3:14 pm Post subject: |
|
|
Hi monte,
mohrt wrote: | Try changing that:
[php:1:a504dd016b]if(is_array($_ret) && in_array($_full_field, $_ret)) {[/php:1:a504dd016b]
(kills, this is in the _failed_fields() method) |
my suggestion for this bug:
delete line 211:
Code: | $_ret = !$_ret ? false : $_empty; |
Bye,
Markus |
|
Back to top |
|
TGKnIght Smarty Junkie
![](images/avatars/gallery/Avatar_Pack_1/523.gif)
Joined: 07 Sep 2005 Posts: 580 Location: Philadelphia, PA
|
Posted: Tue Apr 04, 2006 3:25 pm Post subject: |
|
|
tpr wrote: | I came up with a better solution for my suggesting.
Code: |
<div style="display:{$error|default:none}">
<tr>
<td>&</td>
<td class="error" style="padding: 10px;">
{validate id="vname" message="& Name cannot be empty<br />"}
{validate id="vband" message="& Band cannot be empty<br />"}
{validate id="vaddress" message="& Address cannot be empty<br />"}
{validate id="vcity" message="& City cannot be empty<br />"}
{validate id="vstate" message="& State cannot be empty<br />"}
{validate id="vzip" message="& Zip cannot be empty<br />"}
{validate id="vphone" message="& Phone cannot be empty<br />"}
{validate id="vemail" message="& Email cannot be empty<br />"}
{validate id="vemailvalid" message="& Email must be valid<br />"}
</td>
</tr>
</div>
|
if error occurs
Code: |
$smarty->assign('error','inline');
|
|
Alternatively you could use this if you want to be able to place your error messages anywhere without manually wrapping each one.
http://smarty.incutio.com/?page=validate_set_params _________________ Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template |
|
Back to top |
|
TGKnIght Smarty Junkie
![](images/avatars/gallery/Avatar_Pack_1/523.gif)
Joined: 07 Sep 2005 Posts: 580 Location: Philadelphia, PA
|
|
Back to top |
|
barma3 Smarty Rookie
Joined: 12 May 2005 Posts: 5
|
Posted: Sun Apr 09, 2006 10:04 am Post subject: |
|
|
tpr, try this:
{validate id="vname" message="& Name cannot be empty<br />" assign="error_vname"}
...
{if isset($error_vname)}{$error_vname}{/if} |
|
Back to top |
|
barma3 Smarty Rookie
Joined: 12 May 2005 Posts: 5
|
Posted: Sun Apr 09, 2006 10:59 am Post subject: |
|
|
It's very strange! In my new project I'm using SmartyValidate 2.7 and ASSIGN param in template doesn't work! I'm using this code:
In PHP:
[php:1:3ae8171f6f]SmartyValidate::register_validator('fst', 'fst', 'notEmpty', false, false, 'trim, capitalize');[/php:1:3ae8171f6f]
In template:
Code: | {validate id="fst" message="Enter you firstname!" assign="error_fst"} |
But value in message param doesn't assign to $error_fst variable. Is it bug or I'm doing something wrong? |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Mon Apr 10, 2006 10:14 am Post subject: |
|
|
TGKnIght wrote: | I will try the suggestions out sometime this week, time permitting. |
Does one of the solutions solve your problem? |
|
Back to top |
|
gmurphey Smarty n00b
Joined: 14 Apr 2006 Posts: 3
|
Posted: Fri Apr 14, 2006 10:00 am Post subject: |
|
|
I just upgraded to 2.7 tonight and my assign parameter isn't working anymore. This sounds a lot like barma's problem.
[php:1:0ff4be883b]SmartyValidate::register_validator('valid_email', 'email', 'isEmail', false, true);[/php:1:0ff4be883b]
Code: | {if $error != ''}<p class="error">{$error}</p>{/if}
{validate id="valid_email" message="Please enter a valid email address." assign="error"} |
$error never shows up. I turned debugging on, and it shows that $error is "Please enter a valid email address.", but it still never displays the message to screen.
Thanks,
Garrett |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Apr 14, 2006 10:50 pm Post subject: |
|
|
It has something to do with a change in the way error messages are handled between the form and the session. As a work around, place your {validator} tags before your test on the assigned $error var in the template. |
|
Back to top |
|
gmurphey Smarty n00b
Joined: 14 Apr 2006 Posts: 3
|
Posted: Fri Apr 14, 2006 10:57 pm Post subject: |
|
|
Thanks Monte. Placing the validators before the outputting the error fixed my problems.
Garrett |
|
Back to top |
|
|