Hello all,
I have a question regarding conditional fields and using validators.
Take the example from the book with a slight change:
db.define_table('purchase', Field('have_coupon', 'boolean'), Field('coupon_code', requires=IS_NOT_EMPTY()))
with controller:
def index():
db.purchase.coupon_code.show_if = (db.purchase.have_coupon==True)
form = SQLFORM(db.purchase).process()
return dict(form = form)
show_if works well but if i need validators in place for when say have_coupon is true, to validate coupon_code I get an error when have_coupon is false as coupon_code is empty.
I would prefer to keep the validator on the model, is there a way to accomplish this.
Regards,
James