> Hi !
>
> I'm building an app in TG2, but my question is about the validation
> mechanism, i've building some kind of web components that wraps a few
> widgets and locate them in a structured html, and the problem is that i
> don't return the forms directly, instead a compound widgets with forms
> and
> other stuff.
> I'm not sure of how tg2 validation mechanism works but i'm really
> interested
> on keeping my web components, is there any way i can make validation for
> it
> ? i mind, how i can catch those messages and manually put them in the form
> ?
> ( or something like that )
>
> ( This web components are the vertebral column of lymon )
If the form is not the root widget you won't be able to use the validate()
decorator TG2 provides but will have to validate "manually", example:
Say we have a form inside widget "panel" called "search_form"
def my_controller(self):
try:
value = panel.c.search_form.validate(request.POST)
except Invalid, error:
# validation failed, re-render the panel but this time pass the
# error and previous values to the form explicitly
panel.c.form.error_at_request = error
panel.c.form.value_at_request = request.POST
return panel.display()
else:
# do something useful
Haven't actually tested the code so tell us how it goes...
Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---