Try with: Is_empty_or(is_in_db(...))
Il giorno mer 6 nov 2019 alle 15:34 Steve <[email protected]> ha scritto: > Hi, > > I have a SQLFORM which has 2 fields referenced all to another Product > table. > In this form you can select 1 or more products but only first is > mandatory, the other one is optional. > > The problem i have is that i don't want all the products in the dropdown > list but only the products which are for example are in stock, the others i > don't want in the list. > For the mandatoy field , i don't have an issue because i use > "requires=IS_IN_DB(......." > > But for the other fields, which are not mandatory, i am not able to filter > the dropdown list, if i use IS_IN_DB that yoou have to fill in the form > field , but as said i would like to leave second product selection optional > > Can anyone help me on my way. > > db.define_table('werkgroep', > Field('omschrijving', requires=IS_NOT_EMPTY()), > Field('product1',requires = IS_IN_DB(db(db.product.stock > <> 1), db.product, '%(first_name)s %(last_name)s'), label=T('Product 1')), > Field('product2',db.product, label=T('Practitioner 2')) > ) > > db.define_table('product', > Field('name',requires=IS_NOT_EMPTY()), > Field('stock', 'integer', requires=IS_NOT_EMPTY() > ) > > Hope you can help me, > > Steve > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/web2py/d4de53e3-5dd2-448a-8e70-0f7e94edfd46%40googlegroups.com > <https://groups.google.com/d/msgid/web2py/d4de53e3-5dd2-448a-8e70-0f7e94edfd46%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Massimiliano -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CANPTPxJ0MOWDQS2tkpBoBVChFerosa-bQtKBynhmx2tTX4mxZQ%40mail.gmail.com.

