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 >> >> >>