I don't think I've personally tested the case where a different Form
instance is used in each location. Otherwise, it seems like this
should work. I'd say open a ticket. Something that could help a lot,
if you have time, is to rearrange the code below into a test case
(check out turbogears.widgets.tests.test_forms for examples). Having
test cases makes things easy to fix and makes sure the bugs stay dead.
Kevin
On Jun 26, 2006, at 5:06 PM, Randall wrote:
>
> SVN 1590 with SQLA patches.
>
> I'm using widgets to create a form and thought that the widgets
> automagically displayed error messages when a FormEncode validation
> failed, but I'm getting back the form with no errors displayed. Here
> is what my code looks like.
>
> class PlanReviewSchema(validators.Schema):
> title = validators.String(not_empty=True)
>
> def createPlanReviewForm(controller=None):
> # some stuff
> form = TableForm(fields=fields, action="save", submit_text="Save",
> validator=PlanReviewSchema())
>
> class PlanReviewController(controllers.RootController,
> RESTfulController):
>
> # Some methods.
> # ...
>
> @expose(template="tgwater.planreview.templates.edit")
> def edit(self, obj):
> form = createPlanReviewForm()
> return dict(project=obj, form=form)
>
> @expose()
> @validate(form=createPlanReviewForm)
> @error_handler(edit)
> def save(self, project, **data):
> tg.flash("Changes saved!")
> raise tg.redirect("/")
>
> I purposely leave the "title" field empty so the validator fails and
> the "edit" method gets called because it is the error_handler. But
> why
> is there not an error message next to "title" on the form?
>
> Randall
>
>
> >
--
Kevin Dangoor
TurboGears / Zesty News
email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---