On Mar 15, 6:28 am, Mengu <whalb...@gmail.com> wrote:
> > First of all, I am not sure what is the problem you are trying to
> > solve. Even if you have custom forms and you build all the form html
> > manually you can still use the existing validation mechanism.
>
> I don't want to use crud or sqlform or any html helper. i build my
> forms manually. and actually if you show me how to make validation
> with manual forms, it would be good.

You could set the error messages in the requires

db.users.name.requires = IS_NOT_EMPTY(error_message = "Please enter
your name")
db.users.email.requires = [
  IS_EMAIL(error_message="Given e-mail is not a valid one."),
  IS_NOT_IN_DB(db,'users.email',error_message="Sorry, this e-mail
already exists in our database")
]

create your form with the same field names and to check them do

for n,v in request.vars.items():
  rr=db.users[n].requires
  if isinstance(rr,list):
    t,e=v,None
    for r in rr:
      t,e=r(t)
      if e: break
  else:
    t,e=rr(v)
  if e:
    form.errors[n]=e

# here do whatever you need to do with form.errors

Denes

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to