i am trying to use SQLFORM.factory in web2py and in one of the tables i have field where i want to use requires 2 times but it gives an error i know there is some way how you are supposed to do it but i dont know how. i am new to web2py
form = SQLFORM.factory(
Field('email', requires=IS_NOT_EMPTY(), requires = IS_EMAIL(error_message='invalid email'))
)
here i want to put both conditions that field email is of type email and should not be empty which are 2 different require fields but how to join them or somthing???
I'm new to web2py as well but I believe you need to put them in a python list. Like this:
form = SQLFORM.factory(
Field('email', requires=[IS_NOT_EMPTY(), IS_EMAIL(error_message='invalid email')])
)
See the documentation where they talk about Multiple validators: http://www.web2py.com/book/default/chapter/07#Validators