And just another example I want to be able to store null or empty emails in my database, even though email field is unique.
but anybody else who signs up must enter a valid new email address. So on my signup form it needs an IS_NOT_EMPTY validator, but on my internal forms i need IS_NULL_OR(...) validators. How should situations like this be handled, should I just always redefine my validators at the .factory level, or define at the databse level as "defaults" and only redefine in .factory if the validators change? -Thadeus On Tue, Jan 26, 2010 at 12:11 PM, Thadeus Burgess <thade...@thadeusb.com> wrote: > Notice how I have validators set on the database level of web2py. > > db.table.field.requires = IS_IN_DB(...) > > I only use SQLFORM.factory to create my forms. I only use > SQLFORM.factory because for my purposes forms cannot be mapped > directly to database tables. > > Take a reference field for example, I want my database to store it as > an ID, however I want the form to allow input as another field in the > reference table, say "name". > > So for this I use a different IS_IN_DB validator for my > sqlform.factories than the IS_IN_DB for a reference field. > > IS_IN_DB(db, 'signup.code') vs IS_IN_DB(db, 'signup.id'), but my > database actually stores the ID, so on form.accepts I query for the > records id. > > So here is my question, are validators used anywhere else in web2py > except by crud and SQLFORM ? Am I safe by not setting validators on > the database level ? > > Now sometimes I will use a field as is straight from the database > (like the gender column), in this case I can see setting a > database-level validator and then when creating my SQLFORM.factory, > just referencing the fields I know arn't special. > > -Thadeus > -- 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.