Hello Anthony, The "_and=" works perfectly and bring back the dropbox, but as you mention, not all the logic of the validator that I pass in the _and= option is working... The IS_EMPTY_OR is overriding the
Here the proper syntax to get the dropbox : db.table.field1.requires =\ IS_EMPTY_OR(IS_IN_DB(db,'table.field1'), _and=ONLY_ONE_CAN_BE_FILLED([request.vars.field2],error_message='Select only one'))) I try to remove the IS_EMPTY_OR, but as expected the IS_IN_DB prevent insertion of a null... Don't know what the best option to make it works properly... Adding option to IS_EMPTY_OR() to allow inter independency with my ONLY_ONE_CAN_BE_FILLED() or make a _and= option to my ONLY_ONE_CAN_BE_FILLED() to make it works with IS_IN_DB?? Richard On Tue, Jun 21, 2011 at 9:11 PM, Richard Vézina <ml.richard.vez...@gmail.com > wrote: > Great thanks Anthony, I will try that tomorrow first time and I will report > back. > > Richard > > > On Tue, Jun 21, 2011 at 5:35 PM, Anthony <abasta...@gmail.com> wrote: > >> When you need to use additional validators with IS_IN_DB but still want >> the dropbox, you can add the additional validators to the IS_IN_DB validator >> via its '_and' argument -- see >> http://web2py.com/book/default/chapter/07#Database-Validators. However, >> I'm not sure if that works when IS_IN_DB is inside an IS_NULL_OR validator. >> (Actually, IS_NULL_OR has been deprecated in favor of IS_EMPTY_OR.) >> >> Anthony >> >> On Tuesday, June 21, 2011 5:16:12 PM UTC-4, Richard wrote: >> >>> Hello, >>> >>> I would like to know if the problem I face coming from the validator that >>> I write or is a IS_IN_DB behavior in case of multiple validators?? >>> >>> Here my validator : >>> >>> class ONLY_ONE_CAN_BE_FILLED(object)**: >>> """Class representing a validator requiring at least one non-empty >>> field in a set. """ >>> def __init__( >>> self, >>> others, >>> error_message='Enter a value in at least one field' >>> ): >>> self.others = others >>> self.error_message = error_message >>> >>> def __call__(self, value): >>> okay = (value, None) >>> error = (value, self.error_message) >>> values = [] >>> values.append(value) >>> values.extend(self.others) >>> empties = [] >>> for v in values: >>> unused_v, empty = is_empty(v) >>> empties.append(empty) >>> if empties.count(False) == 1: >>> return okay >>> else: >>> return error >>> >>> >>> But when i use it like this I lost my dropbox for the FK field1 : >>> >>> db.table.field1.requires =\ >>> [IS_NULL_OR(IS_IN_DB(db,'other**table.id <http://othertable.id> >>> ','%(fieldrepresent)s'**,orderby=('fieldrepresent'))), >>> ONLY_ONE_CAN_BE_FILLED([**request.vars.field2],error_**message='Select >>> a volume or an folder')] >>> >>> I remember I read something about IS_IN_DB and [IS_IN_DB]... >>> >>> Can I have the dropbox and the multiple validators at the same time?? >>> >>> Thanks >>> >>> Richard >>> >>> >>> >