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