On Monday, June 8, 2015 at 8:55:40 AM UTC-4, 黄祥 wrote:
>
> pardon me for not made myself clear enough, what i expect to happen is
> when user choose the *receipt type == Purchase Order* so the field of
> *Purchase
> Order No* *become mandatory field *(either using : notnull = True,
> required = True or requires = IS_NOT_EMPTY() ), so how can i achieve it
> using web2py way?
>
Your current code should work for setting notnull/required, but as I
mentioned, violations will result in Python exceptions being raised, not
friendly form error messages. You probably want something like:
if request.post_vars.receipt_type == 'Purchase Order':
db.receipt_header.purchase_order_no.requires = IS_NOT_EMPTY()
form = SQLFORM(...)
Anthony
--
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].
For more options, visit https://groups.google.com/d/optout.