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

Reply via email to