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

-- 
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/3d651719-e1a6-4bf0-9666-f9f58460f5f4n%40googlegroups.com.

Reply via email to