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 2.7 released
Goto page 1, 2, 3, 4  Next
 
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
mohrt
Administrator


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

PostPosted: Wed Mar 29, 2006 10:27 pm    Post subject: SmartyValidate 2.7 released Reply with quote

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
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Fri Mar 31, 2006 5:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


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

PostPosted: Fri Mar 31, 2006 7:49 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
tpr
Smarty Rookie


Joined: 27 Mar 2006
Posts: 8

PostPosted: Sat Apr 01, 2006 6:37 am    Post subject: Reply with quote

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
View user's profile Send private message
tpr
Smarty Rookie


Joined: 27 Mar 2006
Posts: 8

PostPosted: Sat Apr 01, 2006 7:03 am    Post subject: Reply with quote

see below

Last edited by tpr on Sat Apr 01, 2006 7:05 am; edited 1 time in total
Back to top
View user's profile Send private message
tpr
Smarty Rookie


Joined: 27 Mar 2006
Posts: 8

PostPosted: Sat Apr 01, 2006 7:05 am    Post subject: Reply with quote

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
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Tue Apr 04, 2006 3:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Apr 04, 2006 3:25 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TGKnIght
Smarty Junkie


Joined: 07 Sep 2005
Posts: 580
Location: Philadelphia, PA

PostPosted: Tue Apr 04, 2006 3:27 pm    Post subject: Reply with quote

kills wrote:
Hi monte,

mohrt wrote:
Try changing that:

[php:1:5620f17b23]if(is_array($_ret) && in_array($_full_field, $_ret)) {[/php:1:5620f17b23]

(kills, this is in the _failed_fields() method)


my suggestion for this bug:

delete line 211:
Code:
$_ret = !$_ret ? false : $_empty;



Bye,
Markus


I will try the suggestions out sometime this week, time permitting.
_________________
Smarty site with one index.php controller file
Working with MySQL and Smarty
SmartyColumnSort
Custom Smarty Javascript Debug Template
Back to top
View user's profile Send private message Visit poster's website
barma3
Smarty Rookie


Joined: 12 May 2005
Posts: 5

PostPosted: Sun Apr 09, 2006 10:04 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
barma3
Smarty Rookie


Joined: 12 May 2005
Posts: 5

PostPosted: Sun Apr 09, 2006 10:59 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Mon Apr 10, 2006 10:14 am    Post subject: Reply with quote

TGKnIght wrote:
I will try the suggestions out sometime this week, time permitting.


Does one of the solutions solve your problem?
Back to top
View user's profile Send private message
gmurphey
Smarty n00b


Joined: 14 Apr 2006
Posts: 3

PostPosted: Fri Apr 14, 2006 10:00 am    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Apr 14, 2006 10:50 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
gmurphey
Smarty n00b


Joined: 14 Apr 2006
Posts: 3

PostPosted: Fri Apr 14, 2006 10:57 pm    Post subject: Reply with quote

Thanks Monte. Placing the validators before the outputting the error fixed my problems.

Garrett
Back to top
View user's profile Send private message
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
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
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