Thanks for your answer, I've tried but i get an error:
Am Montag, 10. Februar 2020 17:18:38 UTC+1 schrieb Massimo Di Pierro: > > You need to 1) extend Validator and 2) provide an options method. This > should do: > > > from pydal.validators import Validator > > class IS_IN_SET_CONDITIONAL(Validator): > def __init__(self, liste, expression, error_message="Value not > allowed"): > self.expression = expression > self.error_message = error_message > self.liste = liste > > def __call__(self, value): > if self.expression: > if value in self.liste: > return (value,None) > else: > return(value, self.error_message) > > else: > return (value, None) > def options(self): > return self.liste > > On Sunday, 9 February 2020 21:58:25 UTC-8, Fabian wrote: >> >> Hello Guys, >> >> I made a Validator which should check if the value is in the list, but >> only if an expression is True. >> It works fine BUT it produces no dropdown. Hope you can help me: >> >> Class: >> >> class IS_IN_SET_CONDITIONAL(): >> def __init__(self, liste, expression, error_message="Value not >> allowed"): >> self.expression = expression >> self.error_message = error_message >> self.liste = liste >> >> def __call__(self, value): >> if self.expression: >> if value in liste: >> return (value,None) >> else: >> return(value, self.error_message) >> >> else: >> return (value, None) >> >> >> Field: >> >> Field("Letter", label="Letter", requires=IS_IN_SET_CONDITIONAL(['A', 'B', >> 'C'], Expression)), >> >> >> -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/372bb108-c7c6-4a70-b5eb-32f67f0952dc%40googlegroups.com.