On Thursday, July 7, 2016 at 7:36:57 PM UTC-4, Alfonso Serra wrote: > > Thanks Richard, Anthony, very good answers. >> > > The use case is simple: > For example, query articles with a field of uncatalogued, you can either > select catalogued, uncatalogued or all (doesnt matter if its uncatalogued). > To store such filter i can make use of a boolean tri state, True, False or > None to generate the right query. > > Im not using web2py to represent anything (is not compatible with an admin > template we are using, and it doesnt have to), just using SQLFORM > serverside to process post backs and validate. >
Got it. Keep in mind that it helps if you provide your code and some detail regarding what you are doing. You mentioned using SQLFORM and "storing" the data, but it wasn't clear you were not storing the data in the database and that you simply need the data in form.vars. It's still not quite clear what is going on, though. Do you really need the data in form.vars, or could you just use request.vars instead? Do you eventually store data in the database table? > I can agree with Anthony to a certain point that an undeclared boolean > value should always be False. The most common representation of a boolean > value is a checkbox, but it could be a radio input with 3 values. [None, 0, > 1] > > In this case it would be like: > Field("mybool", "boolean", required = False, notnull = False, default = > None > , filter_in=lambda v: None if v is None else v) > But that would just be equivalent to lambda v: v, which doesn't do any filtering. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.