Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Problem validating fields with names like field[id][item]

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
tangfucius
Smarty Rookie


Joined: 30 Sep 2004
Posts: 16

PostPosted: Thu Sep 30, 2004 8:40 pm    Post subject: Problem validating fields with names like field[id][item] Reply with quote

Here is my session SmartyValidate data:

Array ( [default] => Array ( [registered_funcs] => Array ( [criteria] => Array ( ) [transform] => Array ( ) ) [validators] => Array ( [0] => Array ( [field] => registrants[683802][email] [criteria] => isEmail [message] => Invalid Email address [trim] => [empty] => [halt] => [valid] => ) ) [is_error] => 1 ) )

Here is my _Post Data
Array ( [registrants] => Array ( [683802] => Array ( [prefix] => Mr. [firstname] => [lastname] => [email] => tangyi@hotmail.com [address1] => [address2] => [city] => [state] => [zipcode] => ) ) [submit] => Next Page )


Any solutions would be greatly appreciated.
Back to top
View user's profile Send private message
tangfucius
Smarty Rookie


Joined: 30 Sep 2004
Posts: 16

PostPosted: Thu Sep 30, 2004 8:42 pm    Post subject: Reply with quote

Addtional info:

The problem is that i entered the correct email address format, but it didn't validate. When i changed the field name from registratnts[id][email] to
simply "email", it worked. So my question is, is there anyway to make it validate array elements with SmartyValidate?
Thanks.
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Thu Sep 30, 2004 8:50 pm    Post subject: Reply with quote

It doesn't handle nested arrays like that. (why organize it that way in the form?)

However, if a single form element is an array, the validator is applied to each array element.
Back to top
View user's profile Send private message Visit poster's website
tangfucius
Smarty Rookie


Joined: 30 Sep 2004
Posts: 16

PostPosted: Thu Sep 30, 2004 9:12 pm    Post subject: Reply with quote

ok. great. I took over a project from some other programmer and want to apply smartyvalidate to the forms, however the existing system takes in array form fields. If you can make modifications to it to make it validate nested arrays, it would be great. If not, understandable.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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