Hi all,
a common problem is a constraint on multiple fields. There are few ways to
handle this situation, I tried by using the _before_* callbacks.
Currently, if the the callback return True (which means that the constrains
validation is failed) the sqlform.grid doesn't raise any message or
notification.
Is that the correct behavior?
An example is that:
def index():
def some_logic(f): return True
db.define_table('station',
Field('name'),
)
db.station._before_insert.append(some_logic)
grid = SQLFORM.grid(db.station)
return {'grid':grid}
By using this example, a record will be never stored but the grid will
'correctly' return every time. If you have many items, it will be difficult
to understand what really happened.
I know that I can add session.flash = 'error message' in the some_logic
function to display a flash message in case of error but even in this case
the user will lose the form with the filled fields.
>From my point of view, a possible alternative scenario would be to 'stay'
in the form and to show to the user a general error message on top of the
form.
Any idea?
Paolo
--
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.