Re: Form fields with multiple values
Ian Bicking <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
Pedro Algarvio wrote:
> I'm trying to find a way to validate a form where some of it's fields have
> multiple values.
>
> The fields(to name them) are mail_alias and forward_address, these are the
> ones that *can* get back multiple values.
>
> What I've done on the form is naming each of the mail_alias and
> forward_address ocurrences like mail_alias-0 and forward_address-0 and so
> on so an error can be given for the correct field.
>
> Each of the return values should be checked against validator.Email.
> Altough there are simple usage examples for each of the validators
> formencode has, I think it lacks some more complex example usage, so a
> formencode noob like myself get's his way arround and not scared thinking
> this is way too complex.
I think you need something like this:
class MySchema(Schema):
mail_alias = ForEach(Email())
forward_address = ForEach(Email())
The ForEach validator takes a validator as its argument, and applies it
to every item in a sequence.
--
Ian Bicking | [email protected] | http://blog.ianbicking.org
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642